#include <bits/stdc++.h>
using namespace std;
int main(int argc, const char* argv[]) {
  int n, dig = 0, bin = 0, i = 0, part = 1, summer = 0;
  cin >> n;
  while (n > 0) {
    dig = n % 10;
    if (dig == 7) {
      bin = bin | (1 << i);
    }
    n /= 10;
    i++;
  }
  for (int it = 0; it < i - 1; it++) {
    part *= 2;
    summer += part;
  }
  cout << summer + bin + 1;
  return 0;
}
