#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
const long double pi = 3.14159265359;
vector<long long> v;
void solve(long long x) {
  if (x > 1e9) return;
  v.push_back(x);
  solve(x * 10 + 4);
  solve(x * 10 + 7);
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n;
  cin >> n;
  solve(0);
  sort(v.begin(), v.end());
  for (long long i = 0; i < v.size(); i++)
    if (n == v[i]) return cout << i, 0;
  return 0;
}
