#include <bits/stdc++.h>
using namespace std;
int a, b, c, d, cnt, n, Max;
int main() {
  int ans = 1;
  cin >> a;
  while (a != 0) {
    if (a % 10 == 4)
      cnt += ans;
    else
      cnt += ans * 2;
    ans *= 2;
    a /= 10;
  }
  cout << cnt;
  return 0;
}
