#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int ans = 0;
  long long int count = 1;
  long long int count4 = 0;
  while (n > 0) {
    long long int d = n % 10;
    if (d == 4)
      ans += pow(2, count - 1);
    else if (d == 7) {
      ans += pow(2, count);
    }
    count++;
    n /= 10;
  }
  cout << ans << endl;
}
