#include <bits/stdc++.h>
using namespace std;
unsigned long o(char*, int);
int main() {
  unsigned long n;
  char a[9];
  cin >> n;
  int i = 0;
  while (n > 0) {
    a[i] = (n % 10) + 48;
    n /= 10;
    ++i;
  }
  cout << o(a, i);
  return 0;
}
unsigned long o(char* a, int n) {
  if (n == 1) return (a[0] == '4') ? 1 : 2;
  for (int i = 0; i < n; ++i) {
    if (a[i] == '7') {
      a[i] = '4';
      for (int j = 0; j < i; ++j) a[j] = '7';
      return (o(a, n) + 1);
    }
  }
  --n;
  for (int i = 0; i < n; ++i) a[i] = '7';
  return (o(a, n) + 1);
}
