#include <bits/stdc++.h>
using namespace std;
vector<long long> ve;
long long n, s, ans;
int main() {
  cin >> n;
  for (int i = 1; i <= 9; i++)
    for (long long j = 0; j < 1ll << i; j++) {
      s = 0;
      for (int i1 = 0; i1 < i; i1++) {
        if (j & 1ll << i1) {
          s *= 10;
          s += 4;
        } else {
          s *= 10;
          s += 7;
        }
      }
      ve.push_back(s);
    }
  sort(ve.begin(), ve.end());
  ans = lower_bound(ve.begin(), ve.end(), n) - ve.begin();
  cout << ans + 1;
}
