#include <bits/stdc++.h>
using namespace std;
int main() {
  string second;
  int ans = 0, a = 1;
  cin >> second;
  int k = second.length() - 1;
  for (int i = 1; i < second.size(); i++) {
    ans += (1 << i);
  }
  for (int i = 0; i < second.length(); i++) {
    if (i == k) {
      if (second[i] == '4')
        ans += 1;
      else
        ans += 2;
      continue;
    }
    if (second[i] == '4') continue;
    ans += (1 << (k - i));
  }
  cout << ans;
  return 0;
}
