#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  s = "7" + s;
  for (int i = 0; i < s.length(); i++) s[i] = ((s[i] == '7') ? '1' : '0');
  cout << bitset<64>(s).to_ullong() - 1;
  return 0;
}
