Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

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;
}

C++: #include<iostream>

int main(){
    int n, count = 0;
    bool isprime [1000000];
    for(int i = 0; i < 1000000; i++)
        isprime[i] = true;
    isprime[0] = isprime[1] = false;
    for(int i = 2; i <= 1000; i++){
        if(isprime[i]){
            for(int j = i * 2; j < 1000000; j += i){
                isprime[j] = false;
            }
        }
    }
    while(std::cin >> n){
        count = 0;
        for(int i = 2; i <= n; i++){
            if(isprime[i])
                count++;
        }
        std::cout << count << std::endl;
    }
}

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



void Eratosthenes(int N){

}

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

    int n,m;
    while (std::cin >> n) {
        // std::cout << n << "," << std::endl;
        m = 0;
        int arr[n];
        for(int i = 0; i <= n; i++){
            arr[i] = 1;
        }
        for(int i = 2; i <= sqrt(n); i++){
            if(arr[i]){
                for(int j = 0; i * (j + 2) <= n; j++){
                    arr[i *(j + 2)] = 0;
                }
            }
        }
        for(int i = 2; i <= n; i++){
            if(arr[i]){
                // std::cout << i << std::endl;
                m++;
            }
        }
        std::cout << m << std::endl;
    }
    return EXIT_SUCCESS;
}