#include <bits/stdc++.h>
int main() {
  int a;
  scanf("%d", &a);
  int n = 7, i = 1, sum = 0, k = 1;
  while (a) {
    int num = a % 10;
    if (num == 4)
      sum += 1 * k;
    else
      sum += 2 * k;
    a /= 10;
    i++;
    k *= 2;
  }
  printf("%d", sum);
}
