#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <cstring>
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int res[1000010];
int N = 1000010;
void isPrime(){
  for (int i=2; i<N; ++i)res[i] = 1;
  res[0] = res[1] = 0;
  for (int i=2; i<1000; ++i) {
    if (res[i * i]) {
      int j = i + i;
      for (;j < N; res[j] = 0, j += i); 
    }
  }
  for (int i=1; i<N; ++i) res[i] += res[i-1];
}
int main(void){
  int n;
  isPrime();
  while(cin>>n,n){
    cout<<res[n]<<endl;
  } 
}