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