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