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