#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
string s;
long long N;
int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);
  ;
  cin >> s;
  N = s.length();
  long long idx = (long long)pow(2, N) - 1;
  long long power = N - 1;
  for (long long i = 0; i < s.length(); ++i) {
    if (s[i] == '7') {
      idx += (long long)pow(2, power);
    }
    --power;
  }
  cout << idx << "\n";
}
