#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  long long res = 0;
  int c = 2;
  int nn = n;
  while (nn) {
    res += c;
    nn /= 10;
    c *= 2;
  }
  c /= 2;
  res -= c;
  c = 1;
  while (n) {
    int cur = (n % 10);
    if (cur == 7) res += c;
    c *= 2;
    n /= 10;
  }
  cout << res + 1 << endl;
  return 0;
}
