#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1, 0, 0, 1, -1, -1, 1, 1};
int diry[8] = {0, 1, -1, 0, -1, 1, -1, 1};
long long MOD = 1000000007;
template <typename T_vector>
void output_vector(const T_vector &v, bool line_break = false,
                   bool add_one = false, int start = -1, int end = -1) {
  if (start < 0) start = 0;
  if (end < 0) end = int(v.size());
  for (int i = start; i < end; i++) {
    cout << v[i] + (add_one ? 1 : 0)
         << (line_break    ? '\n'
             : i < end - 1 ? ' '
                           : '\n');
  }
}
void solve() {
  int n;
  cin >> n;
  int ans = 0;
  int i = 1;
  while (n > 0) {
    if (n % 10 == 4)
      ans += i;
    else
      ans += i << 1;
    n /= 10;
    i <<= 1;
  }
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
  return 0;
}
