Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	num := make([]bool, 1000000)

	for sc.Scan() {
		var nmpr int

		n, _ := strconv.Atoi(sc.Text())

		lmt := int(math.Sqrt(float64(n)))

		for i := 2; i <= lmt; i++ {
			for j := 2; i*j <= n; j++ {
				if !num[i*j] {
					num[i*j] = true
				}
			}
		}

		for t := 2; t <= n; t++ {
			if !num[t] {
				nmpr++
			}
		}

		fmt.Println(nmpr)
	}

}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/

bool prime[1000000];
int ans[1000000];

void is_prime(){
  rep(i,1000000)prime[i]=true;
  prime[0]=prime[1]=false;
  REP(i,2,1000000){
    if(prime[i]==true){
      for(int j=i+i;j<1000000;j+=i)prime[j]=false;
    }
  }
  if(debug)rep(i,1000)if(prime[i])cout<<i<<endl;
}

void calc(){
  ans[0]=0;
  REP(i,1,1000000){
    ans[i]=ans[i-1]+prime[i];
  }
}

int main(){
  int n;
  is_prime();
  calc();
  while(cin>>n){
    cout<<ans[n]<<endl;
  }
  return 0;
}

C++: #include<stdio.h>
bool b[1000000];

int main(void)
{
    int a,n,i;
    int count=0;
    int f=1;

    for(i=3;i<1000000;i+=2){
        f=1;
        for(a=2;a*a<=i;a++){
            if(i%a == 0){
                f=0;
                break;

            }
        }
        if(f==1){
            b[i]=1;
        }
    }
    b[2]=1;

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

    printf("%d\n",count);
    count=0;
    }
    return 0;
}

C++: #include<stdio.h>
#include<algorithm>
#include<string.h>
#include<vector>
#include<queue>
//aoj0009
using namespace std;
int n,gs;
vector<int> cun;
char ip[1000003];
void prime()
{
	cun.clear();
	gs=0;
	memset(ip,1,sizeof(ip));
	ip[0]=0;
	ip[1]=0;
	for(int i=2;i<=n;i++)
	{
		if(ip[i]==1)
		{
			gs++;
			cun.push_back(i);
			for(int j=2*i;j<=n;j+=i)
			{
				ip[j]=0;
			}
		}
	}
}
int main()
{
	while(scanf("%d",&n)!=EOF)
	{
		prime();
		printf("%d\n",gs);
	}
	return 0;
}

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

using namespace std;

int main() {
  bitset<1000000> primes;
  int i, j, n;
  while (cin >> n) {
    primes.reset();
    for (i = 2; i <= n; i++)
      if (primes[i] == false)
	for (j = i + i; j <= n; j += i)
	  primes[j] = true;
    cout << n - primes.count() - 1 << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
 
bool CheckPrimeNumber(int number) {
    int max = (int)std::sqrt(number);
    for (int i=3; i<=max; i+=2)
        if (number % i == 0)
            return false;
    return true;
}
 
int main() {
    int n, cnt;
    while (std::cin >> n) {
        if (n < 2) {
	cnt = 0;
        } else if (n == 2) {
	cnt = 1;
        } else {
        	cnt = 1;
        	for (int i=3; i<=n; i+=2)
		if (CheckPrimeNumber(i))
			cnt++;
        }
        std::cout << cnt << std::endl;
    }
    return 0;
}

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


int main() {
  int max =0;
  vector<int> ns;
  vector<int> nums;
  while(!cin.eof()){
    int n=0;
    cin >> n;
    // 求める数の最大値を出す
    max = max > n ? max : n;
    // nsには入力が一覧で入る
    ns.push_back(n);
  }
  for(int i =0 ;i <= max;i++) {
    // 0-maxまで1をいれる。
    nums.push_back(1);
  }

  // 素数の可能性が無いものについては0を入れていく (n >=2)
  for(int i =2 ;i <= max;i++) {
    if(nums[i]==0) {
      continue;
    }
    // 素数の 2～倍はすべて素数ではないのでnを入れる
    for(int ii=i*2 ; ii<=max ; ii+=i) {
      nums[ii] = 0;
    }
  }

  for(int i=0;i<ns.size()-1;i++) {
    int count = 0;
    // 素数の数を数え上げ
    for(int ii=2 ; ii <= ns[i] ; ii++) {
      if(nums[ii]==1) count++;
    }
    cout<<count<<endl;
  }
}

C++: #include <iostream>

using namespace std;

int main()
{
	int i, j, n;
	int count = 0;

	while (cin >> n) {
		for (i = 2; i <= n; i++) {
			for (j = 2; j < i; j++) {
				if (i % j == 0) {
					break;
				}
			}
			if (i == j) {
				count++;
			}
		}
		cout << count << endl;
		count = 0;
	}

	return 0;
}

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

int main(void) {
  int table[MAX_NUM + 1] = {0};
  for(int i = 2; i < MAX_NUM; i++) {
    for(int j = i * 2; j < MAX_NUM; j = j + i) {
      table[j] = 1;
    }
  }

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

  return 0;
}

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

int main(){

	int n, i, j, prmnum;
	bool prm = true;
	while(cin>>n){
		prmnum = 0;
		for( i=2;i<=n;i++ ){
			prm = true;
			for( j=2;j<i;j++ ){
				if( i%j == 0 ){
					prm = false;
					break;
				}
			}
			if(prm)prmnum++;
		}
		cout << prmnum << endl;
	}
	return 0;
}

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

int main(){
    vector<int> prime;
    int n;
    for(int i=2;i<1000000;i++){
        bool isprime=true;
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0){
                isprime=false;
                break;
            }
        }
        if(isprime) prime.push_back(i);
    }
    while(cin >> n){
        for(int i=0;i<prime.size();i++){
            if(prime[i]>n){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(){
  int MAX = 1000000;
  int n;
  int cnt=0;
  vector<bool> num(n);
  
  for(int i=0; i<MAX; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;

  for(int i=2; i*i<=MAX; i++){
    if(num[i]){
      for(int j=i*2; j<MAX; j+=i){
	num[j] = false;
      }
    }
  }

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

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = 998244353;
const double EPS = 1e-9;

bool s[1000000] = {};
int sosu[1000000] = {};
void erast(){
  memset(s,1,sizeof(s));
  s[1] = false;
  s[0] = false;
  REP(i,2,1000){
    if(s[i]){
      REP(j,2,1000000){
        if(i*j>=1000000) break;
        s[i*j] = false;
      }
    }
  }
  REP(i,2,1000000) sosu[i] = sosu[i-1]+s[i];
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    erast();
    int n;
    while(cin >> n){
      cout << sosu[n] << endl;
    }
    return 0;
}