#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b > a) {
    b = a + b;
    a = b - a;
    b = b - a;
  }
  if (b == 0) return a;
  return gcd(b, a % b);
}
int lcm(int a, int b) { return (a * b) / gcd(a, b); }
bool comp(const pair<long long, long long> &a,
          const pair<long long, long long> &b) {
  return a.first * a.second < b.first * b.second;
}
long long powo(long long n, long long m, long long mood) {
  if (m == 0)
    return 1;
  else {
    if (m % 2 == 0) {
      long long ret = powo(n, m / 2, mood) % mood;
      return ((ret % mood) * (ret % mood)) % mood;
    } else
      return ((n % mood) * (powo(n, m - 1, mood) % mood)) % mood;
  }
}
map<pair<int, int>, long long> c;
const int N = 1005;
void combinatorics() {
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (i < j)
        c[{i, j}] = 0;
      else if (i == j || j == 0)
        c[{i, j}] = 1;
      else
        c[{i, j}] = c[{i - 1, j - 1}] + c[{i - 1, j}];
    }
  }
}
vector<long long> v;
void gen_lucky(long long n) {
  if (n > (long long)1000000007) {
    return;
  }
  v.push_back(n);
  gen_lucky(10 * n + 4);
  gen_lucky(10 * n + 7);
}
void solve(int t) {
  gen_lucky(0);
  sort(v.begin(), v.end());
  long long n;
  cin >> n;
  int i = lower_bound(v.begin(), v.end(), n) - v.begin();
  cout << i;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  t = 1;
  for (int i = 0; i < t; i++) {
    solve(i);
    cout << "\n";
  }
  return 0;
}
