#include <bits/stdc++.h>
using namespace std;
int main() {
  string str;
  cin >> str;
  long long sum = 0, n;
  n = str.length();
  sum = (2 * (pow(2, n - 1)) - 1);
  for (int i = str.length() - 1; i >= 0; i--) {
    if (str[i] == '7') {
      sum += pow(2, str.length() - 1 - i);
    }
  }
  cout << sum << endl;
}
