#include <bits/stdc++.h>
using namespace std;
using namespace std;
vector<long long> res;
void solve(long long i) {
  if (i > 1000000010) return;
  res.push_back(i);
  solve(i * 10 + 4);
  solve(i * 10 + 7);
}
int main() {
  solve(0);
  sort(res.begin(), res.end());
  int a;
  cin >> a;
  int sz = res.size();
  for (int i = 1; i <= sz; i++)
    if (a == res[i]) cout << i;
}
