#include <bits/stdc++.h>
using namespace std;
int n, a;
queue<int> q;
int f;
int main() {
  cin >> n;
  q.push(4);
  q.push(7);
  bool traz = true;
  while (traz) {
    a++;
    f = q.front();
    q.push(f * 10 + 4);
    q.push(f * 10 + 7);
    q.pop();
    if (f == n) traz = false;
  }
  cout << a << endl;
}
