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 <cstdio>
#include <sstream>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <cmath>
#include <algorithm>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <iostream>
#include <fstream>
#include <numeric>
#include <string>
#include <vector>
#include <cstring>
#include <map>
#include <iterator>
#define ll long long
using namespace std;
bool status[1000000];
int prime[1000000];
 int N=1000000;
void siv()
{
    int sq=sqrt(N);
    for(int i=4;i<=N;i+=2)status[i]=1;
    for(int i=3;i<=sq;i+=2)
    {
        if(status[i]==0)
        {
            for(int j=i*i;j<=N;j+=i)status[j]=1;
        }
    }
    status[1]=1;
}
void res()
{
    int ans=0;
    for(int i=1;i<=N;i++)
    {
        if(status[i]==0)ans++;
        prime[i]=ans;
    }
}
int main()
{
    siv();
    res();
    int x;
    scanf("%d",&x);
    printf("%d\n",prime[x]);
    return 0;

}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include <numeric>
#include<queue>
#include <sstream>
#include<string.h>
#include<math.h>
using namespace std;
int prime[1000005];
bool is_prime[1000005];
int seve(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(void)
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",seve(n));
    }
    return 0;
}

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

using namespace std;

bool p[3000000];
vector<int> prime;

void init(){
    memset(p,1,sizeof(p));
    p[0] = p[1] = false;
    for(int i = 2; i <= 1000000; i++){
        if(!p[i]) continue;
        for(long long j = 1LL*i*i; j <= 1000000; j += i)
            p[j] = false;
        prime.push_back(i);
    }
}

int CntPrime(int n){
    //vector<int>::iterator it = lower_bound(prime.begin(), prime.end(), n);
    //if( *it > n) it--;
    //return (it - prime.begin() + 1);
    int res = 0;
    for(int i = 0; i < prime.size(); i++){
        if(prime[i] <= n) res++;
        else break;
    }
    return res;
}

int main(){
    init();
    int n;
    while(cin >> n){
        cout << CntPrime(n)<< endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n , ans = 1;

	cin >> n;

	if(n <= 1){
		ans--;
	}

	for(int i = 2; i <= n; i++){
		if(i % 2 != 0 && 9 > i){
			//cout << i << endl;
			ans++;

		}if(i >= 9){
			if(i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0){
				//cout << i << endl;
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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,j,cou;
  while(cin>>a){
    cou=0;
    for(int i=2;i<=a;i++){
      if(i==2){
	cou++;
	continue;
      }
      else if(i%2==0)continue;
      for(j=3;j*j<=i;j+=2)if(i%j==0)break;
      if(j*j>i)cou++;
    }
    cout <<cou<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
  int n;
  while(cin>>n) {
    if(n==1)
      cout<<0<<endl;
    else {
    int no=0;
    for(int i=2;i<=n;i++) {
      for(int j=2;j<i;j++) {
	if(i%j==0) {
	  no++;
	  j=n;
	}
      }
    }
    cout<<n-no-1<<endl; 
  }
  }
 return 0;
}

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

int main() {
	int N;
	while(cin >> N){
		int is_prime[N+1];
		is_prime[0]=0; is_prime[1]=0;
		for(int i=2;i<N+1; i++){
			is_prime[i]=1;
		}
		
		for(int s=2; s<N+1; s++){
		
		if(is_prime[s]==1){	
		for(int i=s*s; i<N+1; i+=s){
			is_prime[i]=0;
		}}
		
		}
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
		
	}
	return 0;
}

C++: /*#include"iostream"
#include"stdio.h"
#include"string.h"
using namespace std;
long kt( string a)
{
	long d=0, d1=0;
	long n=a.size();
	if(97<=a[0]&&a[0]<=122)
	{
			for(long i=1;i<n;i++)
			if(65<=a[i]&&a[i]<=90)
			d++;
	}
	
	for(long i=0;i<n;i++)
	{
		if(65<=a[i]&&a[i]<=90)
		d1++;
	}
	if(d1==n) return 2;
	if(d==n-1) return 1;
	return 0;
}
long main()
{
	
	string a;
	cin>>a;
	long n=a.size();
	if(kt(a)==2)
	{
		for(long i=0;i<n;i++)
		a[i]+=32;
		cout<<a;
		return 0;
	}
	if(kt(a)==1)
	{
		for(long i=1;i<n;i++)
		a[i]+=32;
		a[0]-=32;
		cout<<a;
		return 0;
	}
	else cout<<a;
}
*/

#include <iostream>
using namespace std;

#define long long long
const long N = 1000000;
bool np[N];
long p[N], pp=0;

void eratos() {
    np[0]=np[1]=true;
    for (long i=2; i*i<N; i++) if (!np[i])
        for (long j=i*i; j<N; j+=i) np[j]=true;
}
main()
{
	eratos();
	long n,d=0;
do
{
     d=0;
	cin>>n;
	
	for(long i=1;i<=n;i++)
	if(np[i]==false)
	d++;
	cout<<d<<endl; 

}while(1);
}

C++: #include <iostream>
using namespace std;
bool prime[1000000];
void sieve() {
    fill_n(prime, 1000000, true);
    for (int i=2; i<=1000 && prime[i]; ++i) {
        for (int j=i*i; j<1000000; j+=i) {
            prime[j] = false;
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    sieve();
    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i=2; i<=n; ++i) {
            if (prime[i]) {
                cnt ++;
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}