#include <bits/stdc++.h>
const double PI = acos(-1);
using ll = long long;
using namespace std;
string s;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> s;
  reverse(s.begin(), s.end());
  ll cnt = 0;
  for (int i = 0; i < (int)s.size(); ++i) {
    if (s[i] == '4') {
      cnt += 1 << i;
    } else {
      cnt += 1 << (i + 1);
    }
  }
  cout << cnt << "\n";
  return 0;
}
