#include <bits/stdc++.h>
using namespace std;
vector<long long int> v;
int bil;
void gen(long long int now) {
  if (now > 1000000000LL) return;
  if (now != 0) v.push_back(now);
  gen(now * 10 + 4);
  gen(now * 10 + 7);
}
int main(void) {
  gen(0);
  sort(v.begin(), v.end());
  cin >> bil;
  for (int i = 0; i < v.size(); i++) {
    if (v[i] == bil) {
      cout << i + 1 << endl;
      return 0;
    }
  }
}
