#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  long long int n_copy = n;
  int digits = 0;
  while (n) {
    digits++;
    n = n / 10;
  }
  int count_seven = 0;
  long long int sum = 0;
  while (n_copy) {
    if (n_copy % 10 == 7) {
      sum += 1 << count_seven;
    }
    n_copy = (n_copy) / 10;
    count_seven++;
  }
  int rank = 0;
  for (int i = 1; i < digits; i++) {
    rank = rank + (1 << i);
  }
  cout << sum + rank + 1;
  return 0;
}
