#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (!a) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
const long long MAX = 1e6 + 2047;
const long long mod = 1e9 + 7;
const long long MAX_2 = 1009;
void sout() { cout << "\n"; }
template <typename T, typename... Types>
void sout(T var1, Types... var2) {
  cout << var1 << " ";
  sout(var2...);
}
template <typename T>
void sout(vector<T> arr) {
  for (auto it : arr) {
    cout << it << " ";
  }
  sout();
}
template <typename T>
void sout(set<T> st) {
  for (auto it : st) {
    cout << it << " ";
  }
  sout();
}
void test_case() {
  long long n;
  cin >> n;
  queue<long long> q;
  q.push(4);
  q.push(7);
  set<long long> st;
  st.insert(4);
  st.insert(7);
  while (!q.empty()) {
    long long curr = q.front();
    q.pop();
    st.insert(curr);
    if (curr > n) {
      continue;
    }
    q.push(curr * 10 + 4);
    q.push(curr * 10 + 7);
  }
  vector<long long> arr(st.begin(), st.end());
  long long ans = lower_bound(arr.begin(), arr.end(), n) - arr.begin() + 1;
  cout << ans << "\n";
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);
  long long t = 1;
  while (t--) {
    test_case();
  }
}
