#include <bits/stdc++.h>
using namespace std;
double pi = acos(-1);
void OJ() {}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  vector<string> v;
  long long num = 0, k = 0;
  v.push_back("4"), v.push_back("7");
  while (1) {
    long long n = v.size();
    for (long long i = 0; i < n; i++) {
      for (long long j = k; j < n; j++) {
        string s = v[i] + v[j];
        v.push_back(s);
        num = max(num, stoll(s, nullptr, 10));
        if (num >= 1e9) break;
      }
      if (num >= 1e9) break;
    }
    k = n;
    if (num >= 1e9) break;
  }
  vector<long long> ar;
  for (auto s : v) {
    ar.push_back(stoll(s, nullptr, 10));
  }
  long long i = 0;
  sort(ar.begin(), ar.end());
  unordered_map<long long, long long> m;
  for (auto s : ar) {
    if (m.find(s) == m.end()) m[s] = (++i);
  }
  long long in;
  cin >> in;
  cout << m[in];
}
