#include <bits/stdc++.h>
int main() {
  int i = 0, j;
  int bit[20];
  int re;
  long n;
  scanf("%ld", &n);
  while (n != 0) {
    i++;
    bit[i] = n % 10;
    n = n / 10;
  }
  if (bit[i] < 4) {
    printf("%d\n", (int)pow(2, i) - 2);
    return 0;
  }
  if (bit[i] == 4) {
    j = 1;
    while (j < i) {
      if (bit[j] <= 3) {
        printf("%d\n", ((int)pow(2, i) - 2));
        return 0;
      }
      j++;
    }
    re = (int)pow(2, i) - 2 + 1;
    for (j = 1; j < i; j++) {
      if (bit[j] >= 7) re += (int)pow(2, j - 1);
    }
    printf("%d\n", re);
    return 0;
  }
  if (bit[i] < 7) {
    printf("%d\n", (3 * (int)pow(2, i - 1) - 2));
    return 0;
  }
  if (bit[i] == 7) {
    j = 1;
    while (j < i) {
      if (bit[j] <= 3) {
        printf("%d\n", (3 * (int)pow(2, i - 1) - 2));
        return 0;
      }
      j++;
    }
    re = 3 * (int)pow(2, i - 1) - 2 + 1;
    for (j = 1; j < i; j++) {
      if (bit[j] >= 7) re += (int)pow(2, j - 1);
    }
    printf("%d\n", re);
    return 0;
  }
  printf("%d\n", ((int)pow(2, i + 1) - 2));
  return 0;
}
