#include <bits/stdc++.h>
using namespace std;
int main() {
  string number;
  getline(cin, number);
  ;
  reverse(number.begin(), number.end());
  unsigned long long order = 0;
  for (int i = (0); i < ((int)number.size()); i++) {
    if (number[i] == '4') {
      order += 1 << i;
    } else {
      order += 2 << i;
    }
  }
  cout << order << '\n';
  return 0;
}
