#include <bits/stdc++.h>
using namespace std;
int main() {
  vector<int> vec;
  vec.push_back(4);
  vec.push_back(7);
  int n;
  cin >> n;
  for (int i = 0;; i++) {
    if (vec[i] == 444444444) break;
    vec.push_back(vec[i] * 10 + 4);
    vec.push_back(vec[i] * 10 + 7);
  }
  vector<int>::iterator it = lower_bound(vec.begin(), vec.end(), n);
  cout << it - vec.begin() + 1;
  return 0;
}
