#include <bits/stdc++.h>
using namespace std;
int a[2000], i = 0;
void lucky(long long x = 0) {
  if (x > 1000000000) return;
  a[i++] = x;
  lucky(x * 10 + 4);
  lucky(x * 10 + 7);
}
int main() {
  int n = 0;
  cin >> n;
  lucky();
  for (int i = 0; i <= 1022; i++) {
    int item = a[i];
    int j = i;
    while (j > 0 && a[j - 1] > item) {
      a[j] = a[j - 1];
      j--;
      a[j] = item;
    }
  }
  int ans = 0;
  for (int i = 0; i <= 1022; i++) {
    if (a[i] == n) {
      ans = i;
      break;
    }
  }
  cout << ans;
  return 0;
}
