#include <bits/stdc++.h>
using namespace std;
int main() {
  int a = 0, sum = 0;
  string s;
  cin >> s;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] == '4')
      sum += pow(2, a);
    else
      sum += 2 * pow(2, a);
    a++;
  }
  cout << sum;
}
