#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, digit = 0, sum = 0;
  cin >> n;
  long long int k = n;
  while (n != 0) {
    n = n / 10;
    digit++;
    sum = sum + pow(2, digit);
  }
  long long int yo = pow(2, digit), haha = 0, rev, rem;
  n = k;
  while (n != 0) {
    rem = n % 10;
    rev = rev * 10 + rem;
    n = n / 10;
  }
  while (haha != digit) {
    haha++;
    if (rev % 10 == 4) sum = sum - (yo / pow(2, haha));
    rev = rev / 10;
  }
  cout << sum;
  return 0;
}
