#include <bits/stdc++.h>
using namespace std;
const int maxn = 555;
int n, m;
int an[10][maxn];
int main() {
  while (scanf("%d", &n) != EOF) {
    if (n < 4) {
      printf("0\n");
      continue;
    }
    if (n >= 4 && n < 7) {
      printf("1\n");
      continue;
    }
    int cnt = 2;
    memset(an, 0, sizeof(an));
    an[1][1] = 4;
    an[1][2] = 7;
    for (int i = 2; i < 10; i++) {
      int c = 1;
      int t = 1, j = i - 1;
      while (j) {
        t *= 10;
        j--;
      }
      int flag = 0;
      for (int j = 1; j <= pow(2, i - 1); j++) {
        an[i][c] = 4 * t + an[i - 1][j];
        if (an[i][c] > n) {
          flag = 1;
          break;
        }
        cnt++;
        c++;
      }
      for (int j = 1; j <= pow(2, i - 1); j++) {
        an[i][c] = 7 * t + an[i - 1][j];
        if (an[i][c] > n) {
          flag = 1;
          break;
        }
        cnt++;
        c++;
      }
      if (flag) break;
    }
    printf("%d\n", cnt);
  }
  return 0;
}
