#include <iostream>

using namespace std;

bool found[5000000+1];

int main() {
  // read input
  int N;
  cin >> N;
  // initialize the sieve
  for (int i = 0; i <= N; i++)
    found[i] = false;
  // precalculate the powers
  int p2[23], p3[15], p5[10];
  p2[0] = p3[0] = p5[0] = 1;
  for (int i = 1; i <= 22; i++) p2[i] = 2*p2[i-1];
  for (int i = 1; i <= 14; i++) p3[i] = 3*p3[i-1];
  for (int i = 1; i <= 9; i++) p5[i] = 5*p5[i-1];
  // generate and count
  int result = 0;
  for (int i = 0; i <= 22; i++)      // 2^22 = 4194304 < 5000000
    for (int j = 0; j <= 14; j++)    // 3^14 = 4782969 < 5000000
      for (int k = 0; k <= 9; k++) { // 5^9 = 1953125 < 5000000
        int t = p2[i] + p3[j] + p5[k];
        if (t <= N && !found[t]) {
          result++;
          found[t] = true;
        }
      }
  // output the result
  cout << result << endl;
}
