#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<string> v;
  string s = "";
  int c = 1;
  for (int i = 1; i < 11; i++) {
    for (int j = 0; j < (1 << i); j++) {
      for (int p = i - 1; p >= 0; p--) {
        if (char((j >> p & 1) + '0') == '0')
          s += '4';
        else
          s += '7';
      }
      v.push_back(s);
      s = "";
    }
  }
  vector<string>::iterator it;
  cin >> s;
  for (it = v.begin(); it != v.end(); it++) {
    if (s == *it) break;
    c++;
  }
  cout << c;
}
