#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  string inp;
  cin >> inp;
  int sz = inp.size();
  for (int i = 0; i < sz; i++) n = (n * 10) + (inp[i] - '0');
  int tot = 0, arek, chudna, baal, saal;
  for (int i = 0; i < sz; i++) {
    tot += (1 << i + 1);
    arek = tot;
    chudna = (1 << i + 1);
  }
  arek -= chudna;
  int a, b;
  a = 1;
  b = chudna;
  int i = 0;
  while (a != b && i < sz) {
    a -= 1;
    if (inp[i] == '4') {
      b -= ((b - a) / 2);
    }
    if (inp[i] == '7') {
      a += ((b - a) / 2);
    }
    i++;
    a += 1;
  }
  cout << a + arek << endl;
  return 0;
}
