#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int dig, last, count, a, b, c;
  for (int i = 1; i <= N; i++) {
    a = 0, b = 0, c = 0;
    dig = i;
    for (; dig != 0;) {
      last = dig % 10;
      dig /= 10;
      if (last == 7) a++;
      if (last == 5) b++;
      if (last == 3) c++;
    }
    if (a > 0 && b > 0 && c > 0) count++;
  }
  cout << count << endl;
  return 0;
}
