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] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

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

C++: #include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int prime[1000001];
main(){
    int N;
    while(cin >> N){
        fill(prime,prime+1000001,0);
        for(int i = 2;i*i <= N;i++){
            if(prime[i])continue;
            for(int j = i*2;j <= N;j+=i){
                prime[j] = 1;
            }
        }
        int cnt = 0;
        for(int i = 2;i <= N;i++)if(!prime[i])cnt++;
        cout << cnt << endl;
    }
}

C++: #include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
#define N 1000000

int main(void)
{
    bool a[N];
    int n, count;
    rep(i,N)
        a[i] = true;
    a[0] = a[1] = false;
    for(int i=0;i*i<=N;i++)
    {
        if(a[i])
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
    }
    
    while(cin >> n)
    {
        count = 0;
        
        rep(i,n+1)
        {
            if(a[i])
                count++;
        }
        cout << count << endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;
#define maxn 1000000

int  isprime(int n)
{
  
  int p = 0;
  memset(prime,true,sizeof(prime));
  prime[0] = prime[1] = false;
  for(int i=2;i<=n;i++)
  {
    if(prime[i])
    {
      for(int j=2*i;j<=n;j+=i) prime[j] = false;
      p++;
    }
  }

  return p;
}

int main()
{
     
    int n;
    while(cin>>n)
    {
      bool prime[maxn];
	  cout<<isprime(n)<<endl;
    }
    return 0;
}

C++: #include <stdio.h>
int prime[999999];
int main()
{
    long long n,i,j,k,cou;

    prime[0]=prime[1]=1;
    for(i=2;i*i<=999999;i++)
    {

        if(prime[i]==0)
    {
        for(j=i+i;j<999999;j+=i)
        {
            prime[j]=1;
        }
    }
    }
    while(scanf("%lld",&n)==1)
    {
        cou=0;
        for(k=1;k<=n;k++)
        {
            if(prime[k]==0)
                cou++;
        }
        printf("%lld\n",cou);
    }

    return 0;

}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <string>

#define sf scanf
#define pf printf

using namespace std;

const int Maxn = 1000010;
int prime[Maxn];
int flag[Maxn];
int cnt ;
void _init()
{
    for(int i = 2;i < Maxn;i ++)
    {
        if(flag[i] == 0)
        {
            prime[cnt++] = i;
            for(int j = i * 2;j < Maxn;j += i)
                flag[j] = 1;
        }
    }
}
int Find(int n)
{
    int l = 0,r = cnt;
    while(l <= r)
    {
        int mid = (l + r) / 2;
        if(prime[mid] <= n)
            l = mid + 1;
        else
            r = mid - 1;
    }
    return l;
}
int main()
{
    _init();

    int n;
    while(~sf("%d",&n))
    {
        pf("%d\n",Find(n));
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main( void )
{
	int n;
	cin >> n;

	if ( n <= 0 )
		cout << "0" << endl;
	
	vector <bool> p(n+1, true);

	p[0] = p[1] = false;
	for ( int i = 4; i <= n; i += 2 )
	{
		p[i] = false;
	}

	for ( int i = 3; i <= n; i += 2 )
	{
		if ( p[i] )
		{
			for ( int j = i+i; j <= n; j += i )
			{
				p[j] = false;
			}
		}
	}

	int kotae = 1;
	for ( int i = 3; i <= n; i += 2 )
	{
		if ( p[i] )
			kotae++;
	}

	cout << kotae << endl;

	return 0;
}

C++: #include <stdio.h>
const int MAX_V = 1000000; // 100???????????????????f???????¢\????°???¬?????
int prime[MAX_V+1] ,cnt[MAX_V+1] = {0};
int main(){
		int k,i,n; // 1????????f???????C0????????f????????????????????¢
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1; // 2???????£????f????????????°??????¨
	}
	for(i = 2; i <= MAX_V; i++) {
		cnt[i] = cnt[i-1];
		//printf("")
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0; // ???f??????2???{???????£????{?????????f????????????????????¢
			}
			cnt[i]++;
		}
	}
	while(scanf("%d",&n) != EOF){
		printf("%d\n",cnt[n]);
	}
	return 0;
}

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

C++:  #include <iostream>
using namespace std;
int main(){
	long long n , i , j , ans , num ;
	while(cin>>n){
		ans=0;
		for( i=2 ; i<=n ; i++ ){
			num=0;
			for( j=2 ; j<=n ; j++ ){
				if( i%j ==0 )
					num++;
			}
			if( num<2 )
				ans++;
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <fstream>
#include <string>
#include <map>
#include <stack>
#include <set>
#include <list>
#include <vector>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <sstream>
#include <complex>
#include <bitset>
#include <iomanip>
#include <cctype>
#include <limits>
#include <numeric>
#include <cmath>
#include <functional>
#include <queue>
#include <cstring>

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ull;

#define FORE(k,a,b) for(int k=(a); k <= (int)(b); ++k)
#define FOR(k,a,b) for(int k=(a); k < (int) (b); ++k)

#define pb push_back
#define mp make_pair
#define sfi(a) scanf("%d",&a)
#define pfi(a) printf("%d\n",&a)

typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<uint> uvi;
typedef vector<uvi> uvvi;
typedef vector<vd> vvd;
typedef pair<int,int> ii;
typedef vector<pair<int,int> > vii;
typedef vector<vii> vvii;
typedef pair<uint,uint> uu;
typedef map<string, int> msi;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define FOR_IT(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define contains(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

#define MAX 100000000
#define LMT 10000

int a[10000000];

int main()
{
	int i,j,n,cnt=0;
	while(scanf("%d",&n)==1)
	{
		cnt=0;

		memset(a,0,sizeof(a));

		for(i=2;i<=n;++i){
			if(a[i]==0){
                for(j=i*i;j<=n;j+=i)
                a[j]=-1;

                cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
const int MAX_N = 1000000; // いくつまで調べるか
bool prime[MAX_N + 1]; // 添字が素数ならtrue、それ以外はfalse
void sieve()
{
  prime[0] = prime[1] = false; // 例外処理
  // 配列prime の初期化
  for(int i = 2; i <= MAX_N; ++i)
    prime[i] = true;
  // 素数でないものを調べる
  for(int i = 2; i <= MAX_N; ++i)
    if(prime[i])
      for(int j = i * 2; j <= MAX_N; j += i)
	prime[j] = false;
	}

int is_prime(int n)
{
  return prime[n];
  }

/*bool is_prime(int n)
{
  if(n == 1)return false;
  for(int i = 2; i < n; ++i)
    if(n % i == 0)return false;
  return true;
  }
*/
int main()
{
  //sieve();
  int a;
  while(cin >> a){
    //cin >> a;
    //if(a==EOF)return 0;
    int count=0;
    //int tmp;
    for(int i=1;i<=a;i++){
      if(is_prime(i))count++;
    }
    printf("%d\n",count);
  }
}