Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 0
                        }
                }
        }
}

C++: #include <math.h>
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>

#define YES "YES"
#define NO "NO"
#define space ' '

using namespace std;

void func();

int main(void)
{
	
	func();

	return 0;
}


#define MAXIMUM 1000000
bool table[MAXIMUM];
int cnt[MAXIMUM];
#define not true
#define prime false
void func()
{
	table[0] = not;
	table[1] = not;
	for (int i = 2; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			for (int j = i * 2; j < MAXIMUM; j += i)
			{
				table[j] = not;
			}
		}
	}
	for (int i = 1; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			cnt[i] = cnt[i - 1] + 1;
		}
		else
		{
			cnt[i] = cnt[i - 1];
		}
	}

	int n;
	while (cin >> n, !cin.eof())
	{
		cout << cnt[n] << endl;
	}

}

C++: #include <stdio.h>

bool isPrime(int n);

int main(void){
    int n;
    int primes;
    
    while (scanf("%d", &n)!=EOF){
        primes = 0;
        for (int i=2; i<=n; i++){
            if (isPrime(i)) primes++;
        }
        printf("%d\n", primes);
    }
}

bool isPrime(int n){
    if (n==1 || n%2==0) return false;
    if (n==2) return true;
    for (int t=3; t*t<=n; t+=2){
        if (n%t == 0) return false;
    }
    return true;
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int data[100000];
	int count;
	c[0]=c[1]=0;
	for(i=2;i<100000;i++){
		c[i]=1;
	}

	while((scanf("%d",&n)!=EOF)&&(n!=0)){
		
		count=0;
		for(i=0;i*i<=n;i++){
			data[i]=count;
			if(c[i]==1){
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]=0;
					}
				}
			}
		}

		printf("%d",data[n]);
	}
	return 0;
}

C++: #include <stdio.h>

int main() {
    int i, k, v,scan,an;
    int MAX_V = 100000;
    int count[MAX_V];
    int sum[MAX_V];
    int prime[MAX_V];
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1;
    }
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0;   
            } 
        }
    }
    count[0]=0;
    for(i=1;i<=MAX_V;i++){
        count[i]= count[i-1]+prime[i];
    }
    while(scanf("%d",&scan)!= EOF){
        an=count[scan]-count[0];
        printf("%d\n",an);
    }
    return 0; 
}

C++: #include <stdio.h>

bool mark[1000000];
void init() {
	for(int i=0; i < 1000000; i++) mark[i] = false;
	
	mark[0] = true;
	mark[1] = true;
	for(int i = 2;i < 1000000;i++)
	{
		if(mark[i])
			continue;
		for(int j = i * 2; j < 1000000; j += i)
		{
			mark[j] = true;
		}
		
	}

}
int main() {
	init();
	int n, count=0;
	
	while(scanf("%d", &n) != EOF) {
		for(int i = 2; i < n;i++)
		{
			if(!mark[i])
			{
				count++;
			}
		}
		printf("%d\n", count);
		count = 0;
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

bool a[1000000];

int main()
{
    memset(a, true, sizeof(a));

    for (int i = 2; i*i < 1000000; i++) {
        if (!a[i]) continue;
        for (int j = i*2; j < 1000000; j += i) a[j] = false;
    }

    int n;
    while (~scanf("%d", &n)) {
        int cnt = 0;
        for (int i = 2; i <= n; ++i) cnt += a[i];
        printf("%d\n", cnt);
    }
}

C++: #include <iostream>

using namespace std;

int main(int argc, char const* argv[])
{
	bool flag[1000000];
	int p;

	for( int i = 0;i <= 999999;i++ ) flag[i] = true;

	for( int i = 0;i <= 999999;i++ ){
		if( flag[i] ) {
			p = i + i + 2;
			for( int k = i + p; k <= 999999;k += p ) flag[k] = false;
		}
	}

	while( cin >> p ){
		int count = 0;
		for( int i = 0;i <= p;i++ ) if( flag[i] ) count++;
		cout << count << endl;
	}
}

C++: #include <iostream>
using namespace std;
// エラトステネスのふるい
int main() {
  int n, prime[1000000];
  while (cin >> n) {
    for (int i = 0; i <= n; i++) {
      prime[i] = 0;
    }
    prime[0] = 1;
    prime[1] = 1;
    
    int count = 0;
    for (int i = 0; i <= n; i++) {
      if (prime[i] == 0) {
	count++;
	for (int j = i; j <= n; j += i) {
	  prime[j] = 1;
	}
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

void make_sosu(int ans[]){
    int n, i, j, ind, cnt=0;
    ans[0]=2;ans[1]=3;ans[2]=5;ans[3]=7;
    n=9;
    ind=4;
    while(n<=99999){
        cout << "checing::" << n << endl;
        cnt=0;
        for(i=3;i<n;i++){
            if(n%i==0){
                cnt++;
                break;
            }
        }
        if(cnt==0) {
            ans[ind]=n;
            ind++;
        }   
        n+=2;
     }
}

int main(void){
    int n,i,tmp,ans,sosu[100000]={0};
    make_sosu(sosu);
    while(cin>>n){
        if(n==1) cout << "0" << endl;
        else{
            for(i=0;i<n;i++){
                if(n<sosu[i]){
                    cout << i << endl;
                    break;
                }
            }
        }       
    }
    return 0;
}

C++: #include<iostream>
#define N 1000001
using namespace std;
int main(){
  int n;
  int p[N]={0};
  for(int i=3;i<=N;i+=2) p[i] = 1;
  p[2] = 1;
  for(int i=3;i<=1000;i+=2){
    if(p[i]==1){
      for(int j=2*i;j<=N;j+=i) p[j] = 0;
    }
  }
  while(cin>>n){
    int count = 0;
    if(n==0) break;
    int j = n - 2;
    if(p[j]==1) count++; 
    for(int i=3;i<=n/2;i+=2){
      if(p[i]){
	j = n - i;
	if(p[j]) count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: 



#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

/*
int main(void)
{
	int n;
	vector<int> vecPrime;

	while (cin >> n)
	{
		// vectorの破棄
		vecPrime.clear();

		// nが2以上の時,2のみ追加
		if (n >= 2)
		{
			vecPrime.push_back(2);
		}

		// 奇数のみ探索
		for (int i = 3; i <= n; i += 2)
		{
			// 割り切れたらtrueにする
			bool flagPrime = false;

			// 奇数しかループさせないため、j = 1からでよい
			int size = vecPrime.size();
			for (int j = 1; j < size && vecPrime[j] < sqrt((double)i); j++)
			{
				// 割り切れたら素数でない
				if (i % vecPrime[j] == 0)
				{
					flagPrime = true;
					break;
				}
			}
			// すべて割り切れなかった場合
			if (flagPrime == false)
			{
				vecPrime.push_back(i);
			}
		}

		cout << vecPrime.size() << endl;
	}

	return 0;
}
*/


#define SIZE 100000

int main(void)
{
	int n;
	int prime[SIZE] = {0};

	while (cin >> n)
	{
		int ans = 0;

		// nが2以上の時,2のみ追加
		if (n >= 2)
		{
			prime[0] = 2;
			ans++;
		}

		// 奇数のみ探索
		for (int i = 3; i <= n; i += 2)
		{
			// 割り切れたらtrueにする
			bool flagPrime = false;

			// 奇数しかループさせないため、j = 1からでよい
			for (int j = 1; j < ans && prime[j] < sqrt((double)i); j++)
			{
				// 割り切れたら素数でない
				if (i % prime[j] == 0)
				{
					flagPrime = true;
					break;
				}
			}
			// すべて割り切れなかった場合
			if (flagPrime == false)
			{
				prime[ans] = i;
				ans++;
			}
		}

		cout << ans << endl;
	}

	return 0;
}