#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
int solve();
void precomp();
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t = 1;
  if (0) cin >> t;
  precomp();
  for (int tc = 1; tc <= t; tc++) {
    if (0 && 0) cout << "Case #" << tc << ": ";
    solve();
  }
}
void precomp() { return; }
int solve() {
  int n;
  cin >> n;
  vector<int> a;
  while (n > 0) {
    a.push_back(n % 10);
    n /= 10;
  }
  int sz = a.size();
  int ans = (1 << sz) - 1;
  for (int i = sz - 1; i >= 0; i--) {
    if (a[i] == 7) ans += (1 << i);
  }
  cout << ans << endl;
  return 0;
}
