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