#include <bits/stdc++.h>
using namespace std;
long long n;
long long ans;
void dfs(long long x) {
  if (x > n || x > 1e9) return;
  if (x <= n) ans++;
  dfs(x * 10 + 4);
  dfs(x * 10 + 7);
}
signed main() {
  scanf("%lld", &n);
  dfs(4);
  dfs(7);
  printf("%lld", ans);
  return 0;
}
