#include <bits/stdc++.h>
using namespace std;
int num = 0;
int main() {
  int n;
  cin >> n;
  queue<int> q;
  q.push(0);
  int count = 0;
  while (q.size() > 0) {
    long long int temp = q.front();
    if (temp == n) {
      cout << count;
      return 0;
    }
    q.pop();
    q.push(temp * 10 + 4);
    q.push(temp * 10 + 7);
    count++;
  }
}
