#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3fffffff;
long long ppow(long long a, long long n) {
  long long ans = 1;
  while (n) {
    if (n & 1) ans *= a;
    a *= a;
    n >>= 1;
  }
  return ans;
}
vector<long long> B;
int main() {
  long long A = 0;
  cin >> A;
  long long ans = 0;
  B.push_back(4), B.push_back(7);
  int cnt = 2;
  for (long long i = 1; i < 10; i++) {
    long long a = ppow(10, i) * 4;
    long long aa = ppow(10, i) * 7;
    long long n = B.size();
    int tmp = 0;
    for (long long i = n - 1; i > n - 1 - cnt; i--) {
      long long c = B[i];
      long long d = c + a;
      long long dd = c + aa;
      B.push_back(d);
      B.push_back(dd);
      tmp += 2;
    }
    cnt = tmp;
  }
  sort(B.begin(), B.end());
  for (long long i = 0; i < B.size(); i++) {
    if (B[i] == A) {
      cout << i + 1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
  return 0;
}
