#include <bits/stdc++.h>
using namespace std;
long long N;
vector<long long> V;
void Clac(long long X) {
  V.push_back(X);
  if (X >= N) return;
  Clac(X * 10 + 4);
  Clac(X * 10 + 7);
}
int main() {
  cin >> N;
  Clac(0);
  sort(V.begin(), V.end());
  for (int i = 0; i < V.size(); i++) {
    if (V[i] == N) {
      cout << i << endl;
      return 0;
    }
  }
  return 0;
}
