#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n;
  cin >> n;
  int c = 0;
  int a;
  int sum = 0;
  while (n > 0) {
    a = n % 10;
    if (a == 7) {
      sum += int(1 << c);
    }
    n = n / 10;
    c += 1;
  }
  c = c - 1;
  while (c > 0) {
    sum += 1 << c;
    c--;
  }
  cout << sum + 1;
  return 0;
}
