#include <bits/stdc++.h>
using namespace std;
long long n;
vector<long long> V;
void f(long long v) {
  if (v > 1000000000) return;
  V.push_back(v);
  f(v * 10 + 4);
  f(v * 10 + 7);
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n;
  long long res = 0;
  long long x = ceil(log10((double)n));
  res += pow(2, x) - 2;
  for (int i = 0; i < x; ++i) {
    if (n % 10 == 7) res += pow(2, i);
    n /= 10;
  }
  ++res;
  cout << res << endl;
  return 0;
}
