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 <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;



int main(){
	int n; cin >> n;
	vi p(n + 1, 1);
	p[0] = p[1] = 0;
	int ans = 0;
	rep(i, n + 1) if (p[i]) {
		ans++;
		for (int j = i + i; j <= n; j += i) p[j] = 0;
	}
	cout << ans<< endl;
	return 0;
}

C++: //0009
#include <bits/stdc++.h>
using namespace std;

int main(){
    int n;
    while(cin>>n){
        if(n == 1) {
            cout<<0<<endl;
        }
        else if(n == 2){
            cout<<1<<endl;
        }
        else{
            int num[1000000] = {};
            for(int tmp = 2;tmp != n;tmp++){
                if(num[tmp] == 0)
                for(int i = tmp * 2;i <= n;i += i){
                    num[i] = 1;
                }
            }
            int count = 0;
            for(int i = 2;i != n;i++){
                if(num[i] == 0){
                    count++;
                }
            }
            cout<<count<<endl;
        }
    }
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cctype>
#define rep(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;

int main(){
  int n,ans[1000000]={0};
  bool num[1000000]={true};
  num[1]=true;
  for(int i=2;i<1000000;i++){
    if(num[i]==false){
      for(int j=i+i;j<1000000;j=j+i){
	num[j]=true;
      }
    }
  }

  for(int i=1;i<1000000;i++){
    ans[i]=ans[i-1]+!num[i];
    //cout<<num[i]<<endl;
  }
  while(cin>>n){
    cout<<ans[n]<<endl;
  }
  
  return 0;
}

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

bool isChecked[1000010];
vector <int> prime;

int main() {
	for (int i = 0;i < 1000000; i++) isChecked[i] = false;
	isChecked[0] = true;
	isChecked[1] = true;
	for (int i = 2; i < 1000000;i++) {
		if(isChecked[i]) continue;
		prime.push_back(i);
		for (int j = 1; j * i < 1000000;j++) {
			isChecked[j*i] = true;
		}
	}
	int n;
	while(cin >> n) {
		int i;
		for(i = 0;;i++) {
			if (prime[i] > n) break;
		}
		cout << i << endl;
	}
	return 0;
}

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

int main()
{
	vector<int> pcount;
	int prime[10000];
	int j, k, x, num,count=0;
	while (cin >> num){
		prime[0] += 2;
		x = 1;
		k = 1;
		while (prime[k-1] <= num)
		{
			x += 2;
			j = 0;
			while (j < k && x % prime[j] != 0)j++;
			if (j == k)
			{
				prime[k++];
				count++;
			}
		}
		pcount.push_back(count);
		count = 0;
	}
	for (int i = 0; i < pcount.size(); i++)
	{
		cout << pcount[i] << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
int main(){
	int a[999999]={0},i,j;
	a[1]=1;
	for(i=2;i<=999999;i++){
		if(a[i]==0)for(int j=i*2;j<=999999;j+=i)a[j]=1;}
	int n;
	while(~scanf("%d",&n)){
		int sum=0;
		for(i=1;i<=n;i++){
			if(a[i]==0)sum++;}
		printf("%d\n",sum);}
	return 0;}

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

const int N = 1000010;

bool prime[N];
int number[N];
void init() {
  for (int i=0;i<N;i++) prime[i] = true;
  prime[0] = prime[1] = false;
  for (int i=0;i<=sqrt(N);i++) {
    if (prime[i]) {
      for (int j=i*2;j<N;j+=i) prime[j] = false;
    }
  }
  number[0] = 0;
  for (int i=0;i<N-1;i++) {
    number[i + 1] = number[i] + prime[i + 1];
  }
}

int main() {
  int n;
  init();
  while (cin >> n) {
    cout << number[n] << endl;
  }
}

C++: #include <stdio.h>

int main(void)
{
	int n;
	scanf("%d", &n);
	
	bool *d = new bool [n+1];
	int count = 0;

	for(int i = 0; i <= n; i++)
		d[i] = true;

	for(int i = 2; i <= n; i++){
		if(d[i]){
			count++;
			for(int j = i*2; j <= n; j+=i)
				d[j] = false;
		}
	}
	printf("%d\n", count);



	return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;
int sieve(int n);
int prime[1000000];
bool is_prime[1000000];

int main()
{

	int p = 0;
	for (int i = 0; i <= 999999; i++) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= 999999; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= 999999; j += i) {
				is_prime[j] = false;
			}
		}
	}
	int n;
	while (cin>>n) {
		int i = 0;
		while (prime[i] <= n) {
			i++;
		}
		cout << i << endl;
	}
}

C++: #include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int main(){
  int n;
  int cont;
  while(scanf("%d",&n)!=EOF){
    int a[1000000]={0};
    int cont=0;
    a[1]=1;
    for(int i=2;i<=sqrt(n);i++){
      if(a[i]==0){
      for(int j=2;j<=n;j++){
	a[i*j]=1;
      }
    }
    }
    for(int i=1;i<=n;i++){
      if(a[i]==0)cont++;
    }
    cout<<cont<<endl;
  }
}

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

using namespace std;

int main(){
}

C++: #include<iostream>
#define N_MAX 999999

int prime[( N_MAX + 1 ) / 2 ];
int memo[ N_MAX + 1 ];

int mkprime( void );

int main( void )
{
	int n, i, result;

	prime[0] = 2;

	mkprime();

	while( std::cin >> n ){
		std::cout << memo[n] << std::endl;
	}
	
	return 0;
}

int mkprime( void ){
	int i, j, endindex = 1;

	for( i = 3; i < N_MAX + 1; i++ ){
		if( i % 2 == 1 ){
			for( j = 0; j < endindex; j++ ){
				if( i % prime[j] == 0 ){
					break;
				}
			}
		}

		if( prime[j] == 0 ){
			prime[ endindex ] = i;
			endindex++;
		}

		memo[i] = endindex;
	}
}

C++: #include<iostream>
#include<vector>
#include<string>
#define T 1000000
using namespace std;

signed main() {
	vector<bool>hantei(T, true);
	vector<int>sosuu(T);
	int s = 0;
	for (int a = 2; a < T; a++) {
		if (hantei[a]) {
			s++;
			for (int b = a * 2; b < T; b+=a)hantei[b] = false;
		}
		sosuu[a]=s;
	}
	while (cin >> s)cout << sosuu[s] << endl;
}

C++: #include <iostream>

using namespace std;

void solve(int n) {
	int prime[n];
	int j=0;
	for (int i=2; i<=n; i++) {
		prime[j] = i;
		j++;
	}
	int p;
	for (int i=0; i<n; i++) {
		p = prime[i];
		if (p == -1) continue;
		for (int k=i+1; k<n; k++) {
			if (prime[k]%p == 0)
				prime[k] = -1;
		}
	}
	int count = 0;
	for (int i=0; i<n; i++)
		if (prime[i] != -1) count++;
	cout << count << endl;
}

int main() {
	int n;
	while (cin >> n) {
		if (n<=1) cout << 0 << endl;
		solve(n);
	}
	return 0;
}