#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<string.h>
using namespace std;
const int N=11111;
vector<int> prime;
int sieve(long long n){
   bool arr[n+1];
   int cnt=0;
   memset(arr,true,sizeof(arr));
   for(int i=2;i<=n;++i){
    if(arr[i]){
        prime.push_back(i);
        cnt++;
    }
    for(int j=0;j<prime.size()&&i*prime[j]<n;j++){
        arr[i*prime[j]]=false;
        if(i%prime[j]==0)break;
    }
   }
   return cnt;
}

int main(){
long long num;
int a;
while(true){
    cin>>num;
    if(!num) break;
    a=sieve(num);
    printf("%d\n",a);
}
return 0;
}