Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

C++: /*
	大号水?，拿来?手
*/
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int Find_Number (int x)
{
	int cnt = 0;
	for (int i=2;i<=x;i++)
	{
		bool flag = false;
		for (int j=2;j<=sqrt((double)i);j++)
		{
			if ( i % j == 0)
			{
				flag = true;
				break;
			}
		}
		if (flag == false )
		{
			cnt++;
		}
	}
	return cnt;
}

int main ()
{
	int N;
	scanf("%d",&N);
	cout<<Find_Number (N)<<endl;
	return 0;
}

C++: #include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cctype>
#include <stdlib.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <iterator>

#define rep(i,n) for(i=1;i<=n;i++)
#define Rep(i,n) for(i=0;i<n;i++)
#define For(i,a,b) for(i=a;i<=b;i++)

#define pb(x) push_back(x)
#define sz(x) x.size()

#define mem(ara,val) memset(ara,val,sizeof(ara))
#define eps 1e-9

#define si(x) scanf("%d",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sl(x) scanf("%lld",&x)
#define sll(x,y) scanf("%lld %lld",&x,&y)
#define ss(ch) scanf("%s",ch)
#define pi(x) printf("%d",x)
#define pii(x,y) printf("%d %d",x,y)
#define pl(x) printf("%lld",x)
#define pll(x,y) printf("%lld %lld",x,y)
#define ps(ch) printf("%s",ch)
#define NL printf("\n")
#define debug(x) printf("wow %d !!\n",x)

typedef long long LL;

using namespace std;

bool array[1000010];
int ans[1000010];
int main()
{
    int i,j;
    array[1]=1;
    for(i=2; i*i<=1000005; i++)
    {

        if(!array[i])for(j=i*i; j<=1000005; j=j+i)array[j]=1;
    }
    int cnt=0;
    rep(i,1000005)
    {
        if(array[i]==0)cnt++;
        ans[i]=cnt;
    }
    int n;
    while(si(n) !=EOF)
    {
        pi(ans[n]);
        NL;
    }
    return 0;
}

C++: #include<cstdio>
#include<cstring>
int main(){
 int n,cnt=0;
 scanf("%d",&n);
 int a[n+1];
 memset(a,-1,sizeof(int)*(n+1));
 for(int i=2;i<=n;i++){
 if(a[i]==-1){ cnt++;
 for(int j=i;j<=n;j=j+i) a[j]=0;}
}
return 0;
}

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

void add(int* primes, int& now,int prime) {
	primes[now] = prime;
	now++;
}

int main() {
	int num;
	int primes[1000]; int now = 0;
	while (cin >> num) {
		add(primes, now, Era(num));
	}
	for (int i = 0; i < now; i++) {
		cout << primes[i] << endl;
	}
	return 0;
}

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

using namespace std;

int prime(int n);

int main(){
  vector<int> inp;
  int num,pri;					
  int i=0;

  while(cin>>num){
if(num>999999)break;
    if(num <= 1)inp.push_back(0);
    else{
      pri = prime(num);
      inp.push_back(pri);
    }
    i++;
  }
  int j = 0;
  while(j < i){
    cout<<inp[j]<<endl;
    j++;
  }
}

int prime(int num){
  int count=0;
  bool judge=0;
  for(int i = 2; i <= num; i++){
    judge =1;
    for(int j= 2; j < i; j++){
      if(i%j == 0)judge =0;
    }
    if(judge==1)count = count +1; 
  }
  return count;
}

C++: #define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std; 
int main(){
	int N;
	while (cin >> N){
		int sum =0;
		for(int i=2; i<=N; i++){
			int flag = 1;
			for(int q = 2;q <= sqrt(i);++q){
				if(i % q == 0){
					flag = 0;
				}
			}
			sum += flag;
		}
		cout << sum << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <math.h>

using namespace std;

int prime[100000];
bool is_prime[1000000];

int sosuu(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=i*2; j<=n; j+=i) {
                is_prime[j]=false;
            }
        }
    }
    return p;
}

int main(void){
    int n;
    cin>>n;
    cout<<sosuu(n)<<endl;
    return 0;
}

C++: #ifndef VS
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<math.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {
	cww() { CIN_ONLY{ ios::sync_with_stdio(false); cin.tie(0); } }
}star;
#define DEBUG if(0)
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r) { bool a = l>r; if (a)l = r; return a; }
template <typename T>inline bool chmax(T &l, T r) { bool a = l<r; if (a)l = r; return a; }
namespace prime {
	const int size = 1123456;
	int p[size];
	struct prime {
		prime(){
			REP(i, size)p[i] = 1;
			p[0] = p[1] = 0;
			REP(i, size)if (p[i]) {
				for (int j = i + i; j < size; j += i)p[j] = 0;
			}
			FOR(i, 1, size) {
				p[i] += p[i - 1];
			}
		}
	}prime_init;
}
int main() {
	int n;
	while (cin >> n) {
		cout << prime::p[n] << endl;
	}
}