#include <bits/stdc++.h>
using namespace std;
int ss(int n) {
  string s;
  s = to_string(n);
  int k = s.size();
  int count = 0;
  int x = 0;
  int y = 0;
  int z = 0;
  for (int i = 0; i < k; i++) {
    if (s.at(i) != '3' && s.at(i) != '5' && s.at(i) != '7') {
      count++;
    } else if (s.at(i) == '3') {
      x++;
    } else if (s.at(i) == '5') {
      y++;
    } else {
      z++;
    }
  }
  if (count == 0 && x > 0 && y > 0 && z > 0) {
    return 1;
  } else {
    return 0;
  }
}
int main() {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i += 2) {
    ans = ans + ss(i);
  }
  cout << ans << endl;
}
