#include <bits/stdc++.h>
int main(void) {
  int n = 1, dup, index = 0, i, dig, total;
  scanf("%d", &dig);
  dup = dig;
  while (dig / 10 != 0) {
    dig = dig / 10;
    n++;
  }
  int a[n];
  for (i = n - 1; i >= 0; i--) {
    a[i] = dup % 10;
    dup = dup / 10;
  }
  total = pow(2, n);
  for (i = 0; i < n; i++) {
    if (a[i] == 4)
      index = index;
    else
      index = index + (total / 2);
    total = total / 2;
  }
  index = pow(2, n) + index - 1;
  printf("%d", index);
  return 0;
}
