#include <bits/stdc++.h>
using namespace std;
int n, k, x;
int main() {
  cin >> n;
  x = 1;
  while (n > 0) {
    if (n % 10 == 4)
      k += x;
    else
      k += 2 * x;
    x *= 2;
    n /= 10;
  }
  cout << k;
}
