#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
void solve(long long x) {
  if (x > (long long)(1e9)) return;
  v.push_back(x * 10 + 7);
  v.push_back(x * 10 + 4);
  solve(x * 10 + 4);
  solve(x * 10 + 7);
}
int main() {
  long long n, res = 0, i = 1;
  cin >> n;
  while (n) {
    if (n % 10 == 4)
      res += i;
    else
      res += (i * 2);
    n /= 10;
    i *= 2;
  }
  cout << res;
  return 0;
}
