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