#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, ans = 0, sum = 1;
  cin >> n;
  while (n) {
    if (n % 10 == 4)
      ans += sum;
    else
      ans += sum * 2;
    sum *= 2;
    n /= 10;
  }
  cout << ans;
  return 0;
}
