/* primes.c — count primes <= N (1 <= N <= 5,000,000). Odd-only byte sieve.
   Reads N on stdin, prints the count on stdout. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int main(void){
    long n;
    if(scanf("%ld",&n)!=1) return 0;
    if(n<2){ puts("0"); return 0; }
    long m=(n+1)/2;                 /* index i <-> odd number 2*i+1 */
    unsigned char *c=calloc((size_t)m,1);
    if(!c) return 1;
    long sq=(long)sqrt((double)n);
    for(long p=3;p<=sq;p+=2) if(!c[p/2]){
        long step=p, start=p*p/2;   /* index of p*p, step p in index space */
        for(long j=start;j<m;j+=step) c[j]=1;
    }
    long cnt=1;                     /* prime 2 */
    for(long i=1;i<m;i++) if(!c[i]) cnt++;
    printf("%ld\n",cnt);
    free(c);
    return 0;
}
