Go: package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}

C++: #include<iostream>
#include<cmath>
#include<cstring>
using namespace std;
int a[1000100];
int jud(int n){
	int i;
	for (i=2;i<=sqrt(n);i++){
		if (n%i==0)
		return 0;
	}
	return 1;
}
int main(){
	int n;
	while (cin>>n){
		int i,j,res=0;
		memset(a,0,1000000*sizeof(int));
		for (i=2;i<=n;i++)
		if (!a[i]){
			if (jud[i]){
			res++;
			if (i<1000){
			for (j=i*i;j<1000000;j+=i){
				a[j]=1;
			}
			}
			}
		}
		cout<<res<<endl;
	}
	return 0;
}

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

int main()
{
	int n = 0, x = 0;
	int countdata[1000];
	while (cin >> n) {
		if (n / 1000000 > 0) {
			int count = 0;
			for (int a = 2; a <= n; a++) {
				if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0 || a == 2 || a == 3 || a == 5 || a == 7) {
					count++;
				}
			}
			countdata[x] = count;
			x++;
		}
	}
	for (int a = 0; a < x; a++) {
		cout << countdata[a] << endl;
	}
}

C++: #include<stdio.h>
#include<math.h>

int main(){
 int i,j,n,count,flg;
 scanf("%d",&n);
 for(i=2,count=0;i<=n;i++){
  for(j=2,flg=1;j<=i/2;j++)
   if(i%j==0){ printf("%d\n",i); flg=0; break; }
  count+=flg;
 }
 printf("%d\n",count);
 return 0;
}

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

#define MAX_NUM (1000000)

static int getPrimeNum(int maxVal);

int main(void)
{
  int n;
  
  while (std::cin >> n) {
    std::cout << getPrimeNum(n) << std::endl;
  }
  
  return 0;
}

static int getPrimeNum(int maxVal)
{
  static int searchList[MAX_NUM] = {0};
  static int primeList[MAX_NUM] = {0};
  
  for (int i = 0; i < MAX_NUM; i++) {
    searchList[i] = primeList[i] = 0;
  }
  
  double sqMaxVal = sqrt((double)maxVal) + 1;
  
  for (int i = 2; i <= sqMaxVal; i++) {
    if (searchList[i] == 0) {
      searchList[i] = 1;
      primeList[i] = 1;
      for (int j = i + 1; j <= maxVal; j++) {
        if (j % i == 0) {
          searchList[j] = 1;
        }
      }
    }
  }
  
  for (int i = 2; i <= maxVal; i++) {
    if (searchList[i] == 0) {
      primeList[i] = 1;
    }
  }
  
  int count = 0;
  for (int i = 2; i <= maxVal; i++) {
    if (primeList[i] == 1) {
      count++;
    }
  }
  
  return count;
}

C++: #include <iostream>
using namespace std;
#define x 1000000
int main(){
	bool q[x];
	for(int i=2;i<x;i++) q[i] = true;
	for(int i=2;i<x;i++) if(q[i]) for(int j=2;j<=x/i;j++) q[i*j] = false;
	int n;
	while(cin >> n){
		int a = 0;
		for(int i=2;i<x;i++) if(q[i]) a++;
		cout << a << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main(){
    int a[100000];
    int n;
    a[0]=2;
    int k=1;
while(cin>>n){
    for(int i=3;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(j==k){
                a[k]=i;
                k++;
                break;
             }
            if(i%a[j]==0)break;
        }
    }
    cout<<k<<endl;
    k=1;
 }
}

C++: #include <algorithm>
#include <cstdio>
#include <cstring>

using namespace std;
int N;
int primes[1000000];

void prime() {
    fill(primes, primes + 1000000, 1);
    for (int i = 2; i <= 999999; i++) {
        if (primes[i]) {
            for (int j = i + i; j <= 999999; j += i)
                primes[j] = 0;
        }
    }
}

int main() {
    prime();
    while (~scanf("%d", &N)) {
        int ans = 0;
        for (int i = 2; i <= N; ++i)
            ans += primes[i];
        printf("%d\n", ans);
    }
    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

const int maxn = 1e7+10;

int prime[maxn];
bool is_prime[maxn];

int sieve(const int& n){
	int p = 0;
	fill(is_prime,is_prime+n+1,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 <iostream>
using namespace std;

long mygcd(long a, long b)
{
    if (b == 0) return a;
    if (a < b) return mygcd(b,a);
    return mygcd(a-b,b);
}

int main(void)
{
    long num, length, prime[1000];

    while(cin >> num)
    {
        length = 0;
        int count = 0;
        for (int n = 2; n <= num; n++)
        {
            // judge whether n is prime or not
            bool isPrime = true;
            for(int i=0; i < length-1; i++)
            {
                if (!(n % prime[i]))
                {
                    isPrime = false;
                    break;
                }
            }
            // regist n as prime number
            if (isPrime)
            {
                prime[length] = n;
                length++;
            }
        }
        cout << length << endl;
    }
    return 0;
}

C++: #include<cstdio>
#include<cstring>

const int N = 1000009;
int dp[N];
int isprime[N];

int main()
{
    dp[1] = 0;
    for(int i=2;i<N;i++)
    {
        if(!isprime[i])
            for(int j=2*i;j<N;j+=i)
                isprime[j] = 1;
        dp[i] = dp[i-1] + isprime[i];
    }

    int y;
    while(~scanf("%d",&y))
        printf("%d\n",dp[y]);
    return 0;
}

C++: /*
 * fudq.cpp
 *
 *  Created on: 2015-10-24
 *      Author: bjfudq
 */
#include <functional>
#include <algorithm>
#include <iostream>
//#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,102400000")


#define MEM(a) (memset((a),0,sizeof(a)))
#define LEN(a) (int)strlen((a))
#define fr(a) for(int i=0;i<(a);i++)
#define sf(a) scanf("%d",&(a))
#define sf64(a) scanf("%I64d",&(a))
#define sff(a) scanf("%lf",&(a))
#define sfs(a) scanf("%s",(a))
#define sf2(a,b) scanf("%d%d",&(a),&(b))
#define sf3(a,b,c) scanf("%d%d%d",&(a),&(b),&(c))
#define sf2s(a,b) scanf("%s%s",(a),(b))
#define sf2f(a,b) scanf("%lf%lf",&(a),&(b))
#define sf3f(a,b,c) scanf("%lf%lf%lf",&(a),&(b),&(c))
#define sf264(a,b) scanf("%I64d%I64d",&(a),&(b))
#define sf364(a,b,c) scanf("%I64d%I64d%I64d",&(a),&(b),&(c))
#define pf(a) printf("%d\n",(a))
#define pfc(a) printf("%c",(a))
#define pf64(a) printf("%I64d\n",(a))
#define pff(a) printf("%lf\n",(a))
#define pfs(a) printf("%s\n",(a))
#define pf2(a,b) printf("%d %d\n",(a),(b))
#define pf2s(a,b) printf("%s%s\n",(a),(b));
#define pf2f(a,b) printf("%lf %lf\n",(a),(b))
#define pf264(a,b) printf("%I64d %I64d\n",(a),(b))
#define pfn printf("\n")
#define pfk printf(" ")
#define LL long long

const int N=100010;
const int M=1000010;
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const int dir4[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
const int dir8[8][2]={{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}};
const double eps=1e-12;
const double PI=acos(-1.0);

inline int sign(double x){return (x>eps)-(x<-eps);}
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
/*************************/

int tot,prime[N+10],f[N+10];

void Getprime()
{
	memset(f,0,sizeof(f));
	tot=0;
	for(int i=2;i<=N;i++)
	{
		if(f[i] == 0)
			prime[tot++]=f[i]=i;
		for(int j=0;j<tot && prime[j]<=f[i] && i*prime[j]<=N;j++)
			f[i*prime[j]]=prime[j];
	}
}



int main(){
    Getprime();
    int n;
    while(sf(n)!=EOF){
    	int p=lower_bound(prime,prime+tot,n)-prime;
    	if(prime[p] != n) p--;
    	pf(p+1);
    }
    return 0;
}