#include <bits/stdc++.h>
using namespace std;
queue<int> Queue;
int main(void) {
  register int X, Cnt = 0;
  cin >> X;
  Queue.push(0);
  while (Queue.front() != X)
    Cnt++, Queue.push(Queue.front() * 10 + 4),
        Queue.push(Queue.front() * 10 + 7), Queue.pop();
  cout << Cnt << endl;
  return 0;
}
