#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 1; i <= N; i += 2) {
    bool flag3 = false, flag5 = false, flag7 = false, flag = false;
    int num = i;
    while (num != 0) {
      int d = num % 10;
      if (d == 3)
        flag3 = true;
      else if (d == 5)
        flag5 = true;
      else if (d == 7)
        flag7 = true;
      else {
        flag = true;
        break;
      }
      num /= 10;
    }
    if (flag) continue;
    if (flag3 && flag5 && flag7) {
      cnt++;
    }
  }
  cout << cnt << endl;
}
