#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  long long int ans = 0;
  long long int p = 0;
  while (n > 0) {
    if (n % 10 == 4)
      ans += (1LL << p);
    else
      ans += 2 * (1LL << p);
    n = n / 10;
    p++;
  }
  cout << ans;
}
