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