#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int m = n, i = 0;
  long long count = 0, prod = 1;
  bool flag = 0;
  while (m) {
    int d = m % 10;
    m = m / 10;
    if (count == 0) {
      if (d == 4)
        flag = 1;
      else
        flag = 0;
      prod = 2;
      count++;
    } else if (d == 7)
      prod = prod + (1 << i);
    i++;
  }
  count = 0;
  for (int j = 1; j < i; j++) count = count + (1 << j);
  if (flag) prod--;
  printf("%lld", prod + count);
  return 0;
}
