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