Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

func next()string{
	return sc.Text()
}

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;


long cnt[1000001];

int main(){
	long n;
	cnt[0]=0;cnt[1]=0;cnt[2]=1;
	for(long i=3;i<1000000;i++){
		bool flag=true;
		for(long j=2;j*j<=i;j++)if(i%j==0){
			flag=false;
			break;
		}
		if(flag)cnt[i]=cnt[i-1]+1;
		else cnt[i]=cnt[i-1];
	}
	
	while(cin>>n)cout<<cnt[n]<<endl;
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<vector>
#include<string.h>
using namespace std;
const int N=1000000;
vector<int> prime;
bool arr[N];
void init(){
memset(arr,true,sizeof(arr));
arr[0]=arr[1]=false;
for(int i=2;i<N;++i){
    if(arr[i])
        prime.push_back(i);
    for(int j=0;j<prime.size()&&i*prime[j]<N;j++)
    {
        arr[i*prime[j]]=false;
        if(i%prime[j]==0)
            break;
    }
}
}
int main(){
int n;
init();
while(scanf("%d",&n)!=EOF){
    int j=0;
    for(;prime[j]<=n;j++);
    printf("%d\n",j);
}
}

C++: #include <iostream>
#define MAX_N 1000000
using namespace std;

int prime[MAX_N];
bool is_prime[MAX_N+1];

int sieve(int n) {
  int p = 0;
  for(int i=0;i<=n;i++) {
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;
  for(int i=2;i <= n;i++) {
    if(is_prime[i]) {
      prime[p++] = i;
      for(int j=2 * i;j<= n;j += i) is_prime[j] = false;
    }
  }
  return p;
}

int main() {
  int n;
  while(cin >> n) {
  cout << sieve(n) << endl;
  }
}

C++: #include<stdio.h>
#define MAX 1000010

int main(){
	bool prime[MAX];
	prime[0]=prime[1]=0;
	for(int i=0;i<MAX;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=2;i<MAX;i++){
		if(prime[i]==1){
			for(int j=2;i*j<MAX;j++){
				prime[i*j]=0;
			}
		}
	}
	int prime_under_num[MAX];
	prime_under_num[0]=0;
	for(int i=1;i<MAX;i++){
		prime_under_num[i]=prime_under_num[i-1]+prime[i];
	}
	
	int n;
	while((scanf("%d",&n))!=EOF){
		printf("%d\n",prime_under_num[n]);
	}
	
	
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <string>
#define rep(x,to) for(x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)
#define num  1000000

using namespace std;




int main(void){

int innum,i;

char Find[num]; // 探索リスト
	for(int i = 2; i <= num; i++){
		Find[i] = '0';
		if(i%2==0) Find[i] = '1';
	}
	for(int i = 2; i*i < num; i++){
    	if(Find[i] > '0') continue; // すでに除いた数は飛ばす
    	for(int j = i * 2; j< num; j += i) {
        	if(Find[j]=='0') Find[j] = '1';
    	}
	}
	Find[2]='0';
	while(cin >> innum){
		int cnt=0;
		rep(i,innum+1) if(Find[i]=='0') { 
		//	cout << i << " ";
			cnt++;
		}

		cout << cnt <<endl;
	}
	return 0;
}

C++: #include<bits//stdc++.h>
using namespace std;
int main(){
	int a[1000000];
	a[0]=2;
	int z=1;
	for(int i=2;i<1000000;){
		for(int j=0;j<z;j++){
			if(i%a[j]==0)goto stop;
		}
		a[z]=i;
		z++;
		stop:;
		if(i==2) i++;
		else i+=2;
	}
	int b;
	while(cin>>b){
		int c=0;
		for(int i=0;i<z;i++){
			if(a[i]>b)break;
			else c++;
		}
		cout<<c<<endl;
	}
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<string>
#include<cmath>
typedef long long int ll;


using namespace std;
bool priN[1000000]={};
bool pri[1000000]={};

bool isPrime(int n){
	if(priN[n]==true)return pri[n];
	for(int i=3;i<=sqrt((double)n);i++){
		if(n%i==0){
			priN[n]=true;
			pri[n]=false;
			return false;
		}
	}
	priN[n]=true;
	pri[n]=true;
	return true;
}

int main(){
	while(1){
		int n;
		if( !(cin>>n) )break;
		ll sum=1;
		if n<2 sum--;
		for(int i=3;i<=n;i+=2){
			if(isPrime(i))sum++;
		}
		cout<<sum<<endl;
	}
	return 0;
}

C++: #include <cmath>
#include <iostream>

using namespace std;

bool isprime(int N)
{
	for (int I = 2; I <= sqrt(N); I++)
	{
		if (N % I == 0) return false;
	}

	return true;
}

int main()
{
	int c = 0;

	int n;

	if (cin >> n)
	{
		for (int i = 2; i <= n; i++)
		{
			if (isprime(i) == true)
			{
				c += 1;
			}
		}
	}

	cout << c << endl;

	return 0;
}

C++: #include <iostream>
using namespace std;

#define Max 1000000

int isPrime[Max];

int main(){
    int num;
    int i,j;

    //配列の初期化
    isPrime[0] = isPrime[1] = 0;
    for(i = 2; i < Max; ++i){
        isPrime[i] = 1;
    }

    for(i = 2; i < Max; i++){
        if(isPrime[i] == 1){
            if(i % 2 == 0){
                isPrime[i] = 0;
            }else if(i % 3 == 0){
                isPrime[i] = 0;
            }else if(i % 5 == 0){
                isPrime[i] = 0;
            }else if(i % 7 == 0){
                isPrime[i] = 0;
            }
        }
    }

    isPrime[2] = 1;isPrime[3] = 1;isPrime[5] = 1;isPrime[7] = 1;

    while(cin >> num){
        int count = 0;
        for(i = 2; i <= num; ++i){
            if(isPrime[i] == 1){
                count++;
            }
        }
        cout << count << endl;
    }
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;

int main(){
bool unti[1000000];
fill(unti,unti+1000000,0);
for(int n = 2;n < 1000000;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 1000000;a++)
{
	unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt ;
	}
return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int main(){ 
    int n;
    int prime[1000000];
    while(cin>>n){
    for(int i=0;i<1000000;i++)prime[i]=0;
    for(int i=2;i<=n;i++){ 
        for(int j=2;i*j<=n;j++){ 
            prime[i*j]=1;
        }
    }
    int ans=0;
    for(int i=2;i<=n;i++){
        if(prime[i]==0)ans++;
    }
    printf("%d\n",ans);
    }
}