#include <bits/stdc++.h>
using namespace std;
vector<int> lucky;
void luckyones(long long int N) {
  if (N > 1000000000) {
    return;
  }
  if (N) {
    lucky.push_back(N);
  }
  luckyones(N * 10 + 4);
  luckyones(N * 10 + 7);
}
int main() {
  long long int n;
  cin >> n;
  luckyones(0);
  sort(lucky.begin(), lucky.end());
  for (int i = 0; i < int(lucky.size()); i++) {
    if (lucky[i] == n) {
      cout << i + 1;
      return 0;
    }
  }
}
