#include<iostream>
#define N 999999
#define FOR(i,a,b) for( int i = ( a ); i < ( b ); i++ )
#define WHILE(n) while( std::cin >> n )
int p[(N+1)/2];int m[N+1];int mk();using namespace std;int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<'\n';}return 0;}int mk(){int i,j,e=1;FOR(i,3,N){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}