#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, cnt = 1, ans = 1;
  cin >> n;
  long long k = n, c = 0;
  while (k > 0) {
    k /= 10;
    c++;
  }
  while (n > 0) {
    if (n % 10 == 4) {
      cnt *= 2;
      n /= 10;
      continue;
    }
    if (n % 10 == 7) {
      ans += cnt;
      cnt *= 2;
      n /= 10;
    }
  }
  long long s = 0;
  for (int i = 1; i < c; i++) {
    ans += pow(2, i);
  }
  cout << ans;
  return 0;
}
