#include <bits/stdc++.h>
using namespace std;
int main() {
  queue<long long int> q;
  q.push(4);
  q.push(7);
  vector<long long int> v;
  v.push_back(4);
  v.push_back(7);
  while (!q.empty()) {
    int temp = q.front();
    q.pop();
    long long int x = temp;
    long long int dig = 1;
    while (x != 0) {
      x /= 10;
      dig *= 10;
    }
    long long int num1 = dig * 4ll + temp;
    long long int num2 = dig * 7ll + temp;
    if (num1 > 1000000000ll || num2 > 1000000000ll) break;
    v.push_back(num1);
    v.push_back(num2);
    q.push(num1);
    q.push(num2);
  }
  sort(v.begin(), v.end());
  int nx;
  cin >> nx;
  cout << 1 + (find(v.begin(), v.end(), nx)) - v.begin();
  return 0;
}
