#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
void go() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed;
  cout << setprecision(20);
}
void solve() {
  long long n;
  cin >> n;
  long long power = 1;
  long long ans = 0;
  while (n) {
    long long rem = n % 10;
    if (rem == 4) {
      ans += 1 * power;
    } else {
      ans += 2 * power;
    }
    power *= 2;
    n /= 10;
  }
  cout << ans;
}
signed main() {
  go();
  long long t = 1;
  while (t--) solve();
}
