#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int d = n % 10;
  int t = 0;
  int c = 0;
  while (d != 0) {
    c++;
    if (d == 7) t += 1 << c;
    n /= 10;
    d = n % 10;
  }
  cout << t / 2 + (1 << c) - 1 << endl;
}
