#include <bits/stdc++.h>
using namespace std;
const int long long inf = numeric_limits<int long long>::max();
struct __io {
  __io() {
    ios_base::Init i;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
  }
} __io;
signed main() {
  string s;
  cin >> s;
  int long long n = s.length();
  int long long p = (1 << n) - 1;
  for (int long long i = 0; i < n; ++i) {
    if (s[i] == '7') {
      p += 1 << (n - i - 1);
    }
  }
  cout << p << endl;
}
