Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

C++: /*
http://blog.csdn.net/liuke19950717
*/
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef int ll;
const int maxn= 999999+5;
ll prime[maxn];
int main()
{
	ll cnt=0;
	for(ll i=2;i<maxn;++i)
	{
		if(!prime[i])
		{
			prime[i]=++cnt;
			for(ll j=i*i;j<maxn;j+=i)
			{
				prime[j]=1;
			}
		}
		else
		{
			prime[i]=prime[i-1];
		}
	}
	ll n;
	while(~scanf("%lld",&n))
	{
		printf("%lld\n",prime[n]);
	}
	return 0;
}

C++: #include <stdio.h>

void cnt(int i) {
	int j,k,l,m;
	l=0;
	m=0;
	for(j=1;j<=i;j++){
		for(k=1;k<=j;k++){
			if(j%k == 0){
				l++;
			}
		}
		if(l == 2){
			m++;
		}
		l=0;
	}
	printf("%d\n",m);
}

int main(void){
	int i;
	while (scanf("%d", &i) != EOF){
		cnt(i);
	}
}

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

int main()
{
	int n[30];
	int i=0;
	while(cin >> n[i]) {i++;}
		
	for (int k=0;k<i;k++){
		int s=1;
		for (int j=3;j<=n[k];j++){
			for(int m=2;m<j;m++){
				if(j%m==0){break;}
				if(m==j-1){s=s+1;}
			}
		}
		cout << s << endl;
	}	
    return 0;
}

C++: #include <iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=999999+5;
int prime[maxn];
bool is_prime[maxn];
int sieve(int n)
{
    int p=0;
    fill(is_prime,is_prime+n+1,true);
    is_prime[0]=is_prime[1]=true;
    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;
    }
    return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>

#define add push_back
#define inf 2147000000

#define rep(i,n) for(int i=0;i<n;i++)
#define out(a) cout<<a<<endl;

using namespace std;

int main(void){
	int sosuu[100000];
	int cont=0;
	int n;
	scanf("%d",&n);
	
	for(int i=2;i<=n;i++){
		for(int j=0;;j++){
			if(j==cont){
				sosuu[cont]=i;
				cont++;
				break;
			}
			if(i%sosuu[j]==0){
				break;
			}
		}
	}
	out(cont);
}

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) return false;
    for (int t=2; t*t<=n; t++){
        if (n%t == 0) return false;
    }
    return true;
}

C++: #include"iostream"

using namespace std;
int sum;
int prime(int n) {
	if (n > 2 && !(n & 1) || n < 2)
		return 0;
	for (int i = 3; i*i <= n; i += 2)
		if (!(n%i))
			return 0;
	sum++;
	return 0;
}

int main()
{
	int n,t=1;
	int *p;
	while (cin >> n)
	{
		sum = 0;
		p = new int[n];
		for (int i = 1; i <= n; i++)
			p[i] = prime(i);
		cout << sum << endl;
		t++;
		if (t > 30)
			break;
	}
	return 0;
}

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

int main() {
	int N;
	while(cin >> N){
		int is_prime[N+1];
		is_prime[0]=0; is_prime[1]=0;
		for(int i=2;i<N+1; i++){
			is_prime[i]=1;
		}
		
		for(int s=2; s<N+1; s++){
		
		if(is_prime[s]==1){	
		for(int i=s*s; i<N+1; i+=s){
			is_prime[i]=0;
		}
}
		
		}
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
		
	}
	return 0;
}

C++: #include<stdio.h>
main(){
	int i,j,n,p[1000000];
	scanf("%d",&n);
	for(i=2;i<=n;i++)
		p[i]=1;
	for(i=2;i<n;i++)
		for(j=2;i*j<=n;j++)
			p[i*j]=0;
	j=0;
	for(i=2;i<n;i++)
		j+=p[i];
	printf("%d\n",j);
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
main(){
	int n,p[10001];
	for(int i=0;i<=10000;++i)p[i]=1;
	p[0]=0;p[1]=0;
	for(int i=2;i<=10000,i*i<10000;++i){
		for(int j=2;j<=10000;++j){
			if(p[i]==0)break;
			if(j%i==0 && i!=j)p[j]=0;
		}
	}
	while(cin>>n){
		int sum=0;
		for(int i=0;i<=n;++i)if(p[i]==1)++sum;
		cout<<sum<<endl;
	}
}

C++: #include <stdio.h>

int main(void){
int n;
while(scanf("%d",&n)!=EOF){
int count=0;
for(int m=2;m<=n;m++){
bool check=true;
for(int i=2;i<m;i++){
if(i!=m && m%i==0){
check=false;
}
}
if(check==true){
count++;
}
}
printf("%d",count);
}
return 0;
}

C++: #include <iostream>

int main() {
	int input;
	while (std::cin >> input) {

	int count = 0; // input??\???????????¶??°????????¨???????´???°???????¨?
	for (; input > 1; input--) {// input???1???????????????????????????????????¨???????????????
		/*
		 * 5
		 * 4
		 * 3
		 * 2
		 */
		bool fl = true;
		for (int i = 2; i < input; i++) // 1 < i < input ????????¶??????????????°????????§?????????
			/*
			 * 5 -> 2, 3, 4
			 * 4 -> 2, 3
			 * 3 -> 2
			 * 2 ->
			 */
			 // ?????????????????°????????¨??????????????????????????????
			if (!(input % i))
				fl = false;

		if (fl)
			count++;
	}

			std::cout << count << std::endl;
	}
}

C++: 
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>N;vect.resize(N);REP(i,_N){cin>>vect[i];}}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
#define beginend(vec) (vec).begin(),(vec).end()


int main() {
	ll n;
	vector<ll> ans;
	while (cin >> n)
	{
		int prime;
		double sqrtmax = sqrt(n);
		vector<ll> primeVec, searchVec;
		FOR(i, 2, n + 1) searchVec.push_back(i);
		do
		{
			prime = searchVec[0];
			primeVec.push_back(prime);
			auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });
			searchVec.erase(itr, searchVec.end());
		} while (prime < sqrtmax);
		ans.push_back(primeVec.size() + searchVec.size());
	}
	Foreach(i, ans) out(i);
	return 0;
}