#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  ;
  long long i = 0, s = 0;
  while (n) {
    long long k = (n % 10 == 4 ? 1 : 2);
    n /= 10;
    s += pow(2, i) * k;
    i++;
  }
  cout << s;
}
int32_t main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int q;
  q = 1;
  while (q--) {
    solve();
    cout << endl;
  }
  return 0;
}
