#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0, sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int temp = i, d = 0;
    while (temp != 0) {
      temp /= 10;
      d++;
    }
    int a[d];
    for (int j = 0; j < d; j++) {
      a[j] %= 10;
    }
    for (int j = 0; j < d; j++) {
      if (a[j] == 5 || a[j] == 3 || a[j] == 7) {
        if (j == d - 1) sum++;
      } else
        break;
    }
  }
  printf("%d\n", sum);
}
