#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, a[11] = {0}, t, z = 0, k, ans = 0, l = 0, r;
  cin >> n;
  while (n) {
    a[z++] = n % 10;
    n /= 10;
  }
  for (int i = 0; i < z; i++) {
    if (a[i] == 4) {
      ans += pow(2, l);
      l++;
    } else {
      ans += (2 * pow(2, l));
      l++;
    }
  }
  cout << ans;
  return 0;
}
