#include <bits/stdc++.h>
using namespace std;
vector<long long> vec;
void make(long long num) {
  vec.push_back(num);
  if (num > 1000000000) return;
  make(num * 10 + 4);
  make(num * 10 + 7);
}
int main() {
  ios::sync_with_stdio(false);
  make(0);
  sort(vec.begin(), vec.end());
  vec.resize(unique(vec.begin(), vec.end()) - vec.begin());
  int n;
  cin >> n;
  cout << lower_bound(vec.begin(), vec.end(), n) - vec.begin() << endl;
  return 0;
}
