#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 0x3f3f3f3f;
ll n;
ll mx = 1e9;
vector<ll> v;
void gen(ll j = 0) {
  ll a = j * 10LL + 4;
  ll b = j * 10LL + 7;
  if (a < mx) {
    v.push_back(a);
    gen(a);
  }
  if (b < mx) {
    v.push_back(b);
    gen(b);
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  gen();
  cin >> n;
  sort(v.begin(), v.end());
  for (int i = 0; i < v.size(); ++i) {
    if (v[i] == n) {
      cout << i + 1 << "\n";
      ;
      return 0;
    }
  }
  return 0;
}
