#include <bits/stdc++.h>
using namespace std;
vector<int> luck;
void push_luck(long long num) {
  if (num > 1000000007) return;
  if (num) luck.push_back(num);
  push_luck(num * 10 + 4);
  push_luck(num * 10 + 7);
}
int main() {
  int N;
  cin >> N;
  push_luck(0);
  sort(luck.begin(), luck.end());
  for (int i = 0; i < int(luck.size()); i++) {
    if (luck[i] == N) {
      printf("%d", i + 1);
      return 0;
    }
  }
}
