Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

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

int main()
{
	int n, x = 0;
	int countdata[1000];
	while (cin >> n) {
		int count = 0;
		for (int a = 2; a <= n; a++) {
			if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0) {
				count++;
			}
		}
		countdata[x] = count+4;
		x++;
	}
	for (int a = 0; a < x; a++) {
		cout << countdata[a] << endl;
	}
}

C++: #include <cstdio>
#define max_n 999999
int prime[max_n];
bool is_prime[max_n+1];
int main(){
    for(int i=0; i<max_n; i++){
        is_prime[i]=true;
    }
    int p = 0;
    is_prime[1]=false;
    is_prime[0]=false;
    for(int i=2;i<max_n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<max_n;j+=i)is_prime[j]=false;
        }
    }

    while(true){
        int n;
        scanf("%d",&n);
        int ans = 0;
        for(int i =0; i<max_n; i++){
            if(prime[i]>n){
                ans = i;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
#define MAXN 2555
#define INF 0x3f3f3f3f
#define v first
#define b second
using namespace std;
const int N = 1000000;
bool prime[N];
int p[N],tot=0;
void init(){
    for(int i = 2; i < N; i ++) prime[i] = true;
    for(int i = 2; i < N; i++){
        if(prime[i]) p[tot ++] = i;
        for(int j = 0; j < tot && i * p[j] < N; j++){
            prime[i * p[j]] = false;
            if(i % p[j] == 0) break;
        }
    }
}

int main()
{
   init();
   int n;
   while(scanf("%d",&n)==1)
   {
      int sum=0;
      for(int i=0;i<tot;i++)
      {
         if(p[i]<=n)
            sum++;
         else break;
      }
      cout<<sum<<endl;
   }
   return 0;
}

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

int main(void) {

	//0005
	/*
	int a, b, G, R, L, r;
	while (cin >> a >> b) {
		R = a;
		L = b;
		int tmp;
		if (b > a) {
			tmp = a;
			a = b;
			b = tmp;
		}
		while (1) {
			r = a%b;
			if (r == 0)break;
			a = b;
			b = r;
		}
		G = b;
		R = R / G;
		L = L / G;
		cout << G << " " << R*L * G << endl;
	}
	*/
	//0006
	/*
	string name;
	cin >> name;
	int L = name.size();
	string Ans;
	for (int i = 0; i < L; i++) {
		Ans += name.substr(L-i-1, 1);
	}
	cout << Ans << endl;
	*/
	//0007
	/*
	int Dept = 100000;
	int week;
	cin >> week;
	for (int i = 0; i < week; i++) {
		Dept = Dept * 1.05;
		if (Dept % 1000 == 0) {
			Dept = (Dept / 1000);
		}
		else {
			Dept = (Dept / 1000 + 1);
		}
		Dept = Dept * 1000;
	}
	cout << Dept << endl;
	*/
	//0008
	/*
	int a, b, c, d;
	int n;
	int count[51];
	for (int i = 0; i < 51; i++) {
		count[i] = 0;
	}
	for (a = 0; a < 10; a++) {
		for (b = 0; b < 10; b++) {
			for (c = 0; c < 10; c++) {
				for (d = 0; d < 10; d++) {
					count[a + b + c + d]++;
				}
			}
		}
	}
	while (cin >> n) {
		cout << count[n] << endl;
	}
	*/
	int n;
	while (cin >> n) {
		if (n == 1) {
			cout << 0 << endl;
			break;
		}
		int count = 1;
		for (int i = 2; i <= n; i++) {
			for (int j = 2; j < i; j++) {
				if (i%j == 0)break;
				if (j == i-1)count++;
			}
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

#define MAXINT 1000000
bool isprime[MAXINT];
ll int sum[MAXINT];
void makeprime(){
	REP(i,MAXINT) isprime[i] = true;
	FOR(i,2,sqrt(MAXINT)+1){
		FOR(j,i+1,MAXINT-1){
			if(j%i==0) isprime[j] = false;
		}
	}
}

int main(){
	makeprime();
	sum[0] = 0;
	sum[1] = 0;
	sum[2] = 1;
	FOR(i,3,MAXINT){
		if(isprime[i]) sum[i] = sum[i-1]+1;
		else sum[i] = sum[i-1];
	}
	ll int n;
	while(cin >> n){
		cout << sum[n] << endl;
	}
}

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

int main() {
	int n, t = 0;
	cin >> n;
	for(int i = 1;i < n + 1;++i){
	   for(int j = 2;j < i;++j){
	   	if(i / j == 0) break;
	   	if(j == i - 1) t++;
	   }	
	}
	cout << t << endl;
	return 0;
}

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

C++: #include<iostream>
using namespace std;
bool arr[1000000];
int main()
{
	int n,p;
	cin>>n;
  	for(int i=2;i<=1000000;i++){
		if(arr[i]==0)
		{
		    p=i;
			for (int j=2;p*j<=1000000;j++)
			{
				arr[p*j]=1;
			}
		}
	}
	int count=0;
	for(int i=2;i<=n;i++){if(arr[i]==0)count++;}
	cout<<count<<endl;
	delete[] arr;
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>

using  namespace std;

typedef long long ll;

int iprime[999999];
bool is_prime[1000000];

int prime(int n)
{
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for(int i = 2; i <= n; ++i)
	{
		if(is_prime[i])
		{
			iprime[p++] = i;
			for(int j = 2*i; j <= n; j += i)
				is_prime[j] = false;
		}
	}
	return p;
}

int main()
{
	int n;
	while(true)
	{
		if(scanf("%d", &n) == EOF)
			break;
			
		printf("%d\n", prime(n));
	}
}

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

using namespace std;

int main()
{
	int n;

	while (cin >> n){
		int pn = 0;
		for (int i = 2; i <= n; i++){
			bool flag = true;
			for (int j = 2; j <= n; j++){
				if (i % j == 0 && i != j){
					flag = false;
					break;
				}
			}
			if (flag) pn++;
		}
		
		cout << pn << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <algorithm>
#include <iomanip>
#include <functional>
#include <numeric>
#include <sstream>

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define PI 3.14159265358979

using namespace std;

//================================================
vector<int>prime(1000000);
vector<bool>is_prime(1000001);

//Sieve of Eratosthenes
int func(int N) {
	int p = 0;

	REP(i, N + 1) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;

	REP2(i, 2, N + 1) {
		if (is_prime[i]) {
			prime[p++];
			for (int j = 2 * i; j <= N; j += i) is_prime[j] = false;
		}
	}
	return p;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);

	int N;
	while (cin >> N) {
		cout << func(N) << "\n";
	}
	return 0;
}