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