#include <bits/stdc++.h>
using namespace std;
vector<long long> v;
void saddas(long long x) {
  if (x > 10e9) {
    return;
  }
  v.push_back(x);
  saddas(x * 10 + 4);
  saddas(x * 10 + 7);
}
int main() {
  long long n;
  cin >> n;
  saddas(0);
  sort(v.begin(), v.end());
  int i;
  for (i = 0; v[i] < n; i++) {
  }
  cout << i;
  return 0;
}
