Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

C++: /*
 * main.cpp
 *
 *  Created on: 2011/04/08
 *      Author: satoki
 *      5:09 ~ 6:03
 *      Wrong Answer : 2
 *      nÈºÌfð¢ÅÀ
 *      Runtime Error : 4
 *      PÂ½ßÉfðZbg
 */
#include <iostream>
#define MAX_iP 1000004 // 664,580 ÔÚÌf = 10,000,019
#define MAX_nP 78499 // ÔºÌÓ¡àßÄ (KvÈfÌ + 1) ðmÛ
using namespace std;

int iN;

// fe[u
bool bPrime[MAX_iP];
int iPrime[MAX_nP];
int nPrime;

void setPrime() {
  // fe[uðì¬
  int i, j;

  nPrime = 0;
  fill(bPrime, bPrime + MAX_iP, true);
  bPrime[0] = bPrime[1] = false;

  for (i = 2; i < MAX_iP; i++) {
    if (bPrime[i]) {
      iPrime[nPrime++] = i;
      for (j = 2; i * j < MAX_iP; j++) {
        bPrime[i * j] = false;
      }
      //if (nPrime == MAX_nP) break;
    }
  }
  //printf("nPrime = %d i = %d\n", nPrime, i);
}

void init() {
  setPrime();
}

bool input() {
  if (scanf("%d", &iN) == EOF) return false;
  return true;
}

int manage() {
  int i;
  for (i = 0; iPrime[i] <= iN; i++);
  return i;
}

int main() {
  init();
  while (1) {
    if (!input()) break;
    printf("%d\n", manage());
  }
  return 0;
}

C++: #include <stdio.h>
int main(void){
	int k,j,a;
	//flag 0=素数 1=そすうじゃない
	int flag[1000000]={1,1};//0,1は除外する
	for(k=2;k<1000;k++){
		if(flag[k]==0){
			for(j=k*k;j<1000000;j+=k)
				flag[j]=1;
		}
	}
	while(~scanf("%d",&a)){
		k=0;
		for(j=0;j<a;j++) if(flag[j]==0) k++;
		printf("%d\n",k);
	}
}

C++: #include<stdio.h>

int pr[50847534];
int x = 0;

int nextpr(int p){
  int nxp = p+2;
  int i;
  int ok;
  x++;
  if(p==2)return 3;
  while(1){
      /*printf("p=%d->",nxp);*/
    for(i=0;pr[i]*pr[i]<=nxp;i++){
      ok = 1;
      if(!(nxp%pr[i])){
        ok = 0;
        break;
      }
    }
    if(ok){
        /*printf("O\n");*/
      return nxp;
    }else{
        /*printf("X\n");*/
      nxp+=2;
    }
  }
}

int main(){
    int n;
    int i;
    pr[0] = 2;
    while(scanf("%d",&n)!=EOF){
        printf("n=%d\n",n);
        i=0;
        if(n-1){
            while(pr[i]<=n){
                printf("prime:%d(%d)\n",pr[i],i+1);
                i++;
                if(i>=x){
                    pr[i] = nextpr(pr[i-1]);
                }
            }
        }
        printf("%d\n",i);
    }
}

C++: #include <iostream>

using namespace std;

bool is_prime(int x)
{
	if (x == 2) return true;
	if (x % 2 == 0) return false;
	for (int i = 3; i*i <= x; i += 2)
		if (x % i == 0)
			return false;

	return true;
}

int main()
{ 
	int n;

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

		if (n > 1) cnt++;
		for (int i = 3; i <= n; i += 2)
			cnt += is_prime(i);

		cout << cnt << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool isprime(int& num)
{
    static int c;
    if(num == 2) return true;
    for(c=2; c <= sqrt(num); c+=1)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans = 0;
    int buff;
    while(cin >> buff);
    {
        for(int d =2; d <= buff; d++)
        {
            if(isprime(d)) ans++;
        }
        cout << ans << endl;
        ans  = 0;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
using namespace std;

bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}

int main(){
int n;

while(~scanf("%d",&n)){
int* table =  new int[1000000];
memset(table,sizeof(table),1);
table[0]=0;

for(int i=1;i<=n;i++){
if(!is_prime(i)) {
for(int j=i;j<=n;j*=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+1000000,1));
}
}

C++: #include <stdio.h>
int isprime(int n){
	int i;
	for(i=2;i<n;i++){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}
int main(){
	int i,n,c;
	while(1){
		if(n == EOF){
			break;
		}
		scanf("%d",&n);
		c=0;
		for(i=2;i<=n;i++){
			if(isprime(i) == 1){
				c++;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){
    int n;
    vector<int> S;
    double a=sqrt(n);
    while(cin>>n){
        S.push_back(2);
        int ans=0;
        for(int i=3; i<=a; i++){
            int judge=0;
            for(int j=0; j<S.size(); j++){
                if(i%S[j]==0)judge=1;
            }
            if(judge==0){
                ans++;
                S.push_back(i);

            }
        }
        cout<<ans+1<<endl;
        S.clear();
    }
    return 0;
}

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

int main()
{
	bool IsPrime[1000010] = {};
	for (int i = 2; i < 999999; i++)
	{ 
		IsPrime[i] = true;
	}
	for (int i = 2; i*i <= 999999; i++)
	{
		if (IsPrime[i])
		{
			for (int j = i * 2; j <= 999999; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}

	int n;
	while (cin >> n)
	{
		int ans = 0;
		for (int i = 0; i <= n; i++)
		{
			if (IsPrime[i]) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

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

//C

const int MAX_N = 1000000;
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 (scanf("%d", &n) != EOF)
	{
		int ans = sieve(n);
		printf("%d\n", ans);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N;

constexpr ll max_n = 1000006;
bool prime[max_n];

void solve(){
    int cnt=0;
    for(int i=2;i<=N;i++) if(prime[i]) cnt++;
    cout << cnt << endl;
}

int main(){
    rep(i,max_n) prime[i]=true;
    for(int i=2;i<max_n;i++){
        if(!prime[i]) continue;
        for(int j=2;i*j<max_n;j++) prime[i*j] = false;
    }

    while(cin>>N){
        solve();
    }
}