#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ar[s.length()];
  for (int i = (0); i <= (s.length() - 1); i++) {
    if (s[i] == '4')
      ar[i] = 0;
    else
      ar[i] = 1;
  }
  long long int sum = 0;
  for (int i = (0); i <= (s.length() - 1); i++) {
    sum = sum + (1 << i);
  }
  for (int i = s.length() - 1; i >= 0; i--) {
    int j = s.length() - 1 - i;
    sum = sum + (ar[i] * (1 << j));
  }
  cout << sum;
  return 0;
}
