#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, c[15], ind = 0, i, p = 0, q;
  cin >> n;
  while (n != 0) {
    ind++;
    c[ind] = n % 10;
    n = n / 10;
  }
  for (i = ind; i >= 1; i--) {
    if (c[i] == 4)
      q = 1;
    else
      q = 2;
    p = p * 2 + q;
  }
  cout << p << endl;
  return 0;
}
