#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, num = 0, cnt = 1;
  cin >> n;
  for (i = n; i > 0; i = i / 10) {
    if (i % 10 == 4) {
      num = num + cnt;
    } else {
      num = num + 2 * cnt;
    }
    cnt = cnt * 2;
  }
  cout << num << endl;
  return 0;
}
