#include <bits/stdc++.h>
using namespace std;
const long long MAX = 2e5 + 10;
vector<pair<long long, long long> > pares;
int main() {
  string s;
  cin >> s;
  long long n = (long long)((s).size());
  long long rpta = 0;
  for (long long i = (long long)(0); i < (long long)(n); i++) {
    rpta *= 2;
    if (s[i] == '4')
      rpta += 1;
    else
      rpta += 2;
  }
  cout << rpta << endl;
}
