#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int sum(int i,int* bit){
	int s = 0;
	while(i > 0){
		s += bit[i];
		i -= i & -i;
	}
	return s;
}

void add(int i, int x,int* bit,int n){
	while(i <= n){
		bit[i] += x;
		i += i & -i;
	}	
}

int main(){
	int* dp = new int[100000];
	fill((int*)dp,(int*)dp + 100000,1);
	dp[0]=0;
	dp[1]=0;
	for(int i=2;i<100000;i++){
		if(dp[i] != 0){
			for(int j=i+i;j<100000;j+=i){
				dp[j] = 0;
			}
		}
	}

	int idx=1;
	int* bit = new int[100000];
	fill((int*)bit,(int*)bit + 100000,0);

	for(int i=2;i<100000;i++){
		if(dp[i] != 0){
			add(idx++,i,bit,100000);
		}
	}

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;
		cout << sum(n,bit) << endl;
	}
}