#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, n, sum = 0;
  scanf("%d", &n);
  int num[21] = {357,  375,  537,  573,  735,   753,    3357,
                 3375, 3537, 3557, 3573, 3575,  3577,   3753,
                 3755, 3757, 3735, 3775, 37755, 335577, 335757};
  for (i = 0; i < 21; i++) {
    if (n > num[i]) sum++;
  }
  printf("%d", sum);
}
