#include <bits/stdc++.h>
using namespace std;
vector<long long int> d;
int main() {
  int z = 0;
  long long int a;
  cin >> a;
  d.push_back(4);
  d.push_back(7);
  int y = 0;
  while (y < 100000) {
    d.push_back(d[y] * 10 + 4);
    d.push_back(d[y] * 10 + 7);
    y++;
  }
  for (int i = 0; i < d.size(); i++) {
    if (d[i] <= a) z++;
  }
  cout << z;
  return 0;
}
