#include <bits/stdc++.h>
using namespace std;
void youCanDoIt() {
  string s;
  cin >> s;
  vector<int> storage(12);
  storage[0] = 0;
  for (int i = 1; i < 12; i++) {
    storage[i] = pow(2, i) + storage[i - 1];
  }
  int length = s.size();
  int maxIndex = storage[s.size()];
  for (int i = 0; i < s.size(), length; i++, length--) {
    if (s[i] == '4') {
      maxIndex -= pow(2, length) / 2;
    }
  }
  cout << maxIndex << endl;
}
void testCase() {
  int cases;
  cases = 1;
  while (cases--) youCanDoIt();
}
int main() { testCase(); }
