#include <bits/stdc++.h>
using namespace std;
const int maxn = 1010;
int count(int n) {
  int hashTable[20] = {0};
  int num[110], k = 0;
  do {
    num[k++] = n % 10;
    n /= 10;
  } while (n != 0);
  for (int i = 0; i < k; i++) {
    hashTable[num[i]]++;
  }
  int flag = 0;
  for (int i = 0; i < 10; i++) {
    if (hashTable[i] > 0) {
      if (i != 3 && i != 5 && i != 7) return 0;
    }
  }
  if (hashTable[3] > 0 && hashTable[5] > 0 && hashTable[7] > 0) {
    return 1;
  } else
    return 0;
}
int main() {
  int T;
  scanf("%d", &T);
  int sum = 0;
  for (int i = 355; i <= T; i += 2) {
    sum += count(i);
  }
  printf("%d", sum);
  return 0;
}
