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 <bits/stdc++.h>

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

bool Judge_PrimeNumber(const int a) {

	if (a < 2) { return false; }
	if (a == 2) { return true; }
	if (a % 2 == 0) { return false; }

	for (int i = 3; i <= a / i; i += 2) {
		if (a%i == 0) {
			return false;
		}
	}
	return true;
}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int n = 0, ans = 0;
	std::vector<int> A;

	while (std::cin >> n) {
		A.push_back(n);
	}

	for (unsigned int i = 0; i < A.size(); i++) {

		if (n == 1) {
			std::cout << 0 << std::endl;
			continue;
		}
		ans = 1;
		for (int j = 3; j <= A[i]; j += 2) {
			if (Judge_PrimeNumber(j)) {
				ans++;
			}
		}
		std::cout << ans << std::endl;
	}

}

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

unsigned isPrime(unsigned x) {
	static std::vector<unsigned> primes{2};
	if (x < 2) {
		return 0;
	}
	if (x == 2) {
		return 1;
	}
	if (primes.back() < x) {
		for (unsigned i = primes.back() + 1; i*i <= x; i++) {
			bool isPrime = std::none_of(primes.begin(), primes.end(), [i](auto d){ return i % d == 0; });
			if (isPrime) {
				primes.push_back(i);
			}
		}
	}
	bool isPrime{true};
	for (auto&& var : primes) {
		if (var >= x) break;
		if (x % var == 0) {
			isPrime = false;
			break;
		}
	}
	return (isPrime) ? 1 : 0;
}

unsigned numOfPrime(const unsigned& x) {
	unsigned sum{};
	static unsigned ntable[999999]{};
	static unsigned maxX{1};
	if (x < 2) {
		return 0;
	}
	if (x == 2) {
		return 1;
	}
	unsigned count_from = std::min(maxX, x);
	sum += ntable[count_from];
	for (unsigned i = count_from + 1; i <= x; i++) {
		sum += isPrime(i);
		ntable[i] = sum;
	}
	maxX = std::max(x,maxX);
	return sum;
}

int main(int argc, char const* argv[])
{
	unsigned d{};
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	while (std::cin >> d) {
		std::cout << numOfPrime(d) << std::endl;
	}
	return 0;
}

C++: #include	<math.h>
#include	<stdio.h>

bool isPrimeNumber(int number){
	if(number	  == 2)	return true;
	if(number % 2 == 0)	return false;
	
	
	for(int i = 3; i <= (int)sqrt((double)number) ;i += 2){
		if(number % i == 0)	return false;
	}
	
	return true;
}

int main(int argc, char** argv){
	
	int search, counter;
	
	while((scanf("%d", &search)) != EOF){
		counter = 0;
		for(int i = 2; i <= search; i++){
			counter += isPrimeNumber(i) ? 1 : 0;		
		}
		printf("%d\n", counter);
	}
	
	return 0;
}

C++: #include <iostream>
#define N 1000000 

using namespace std;

bool sosu[N];

void sosuhyo()
{
	sosu[0]=true;
	sosu[1]=true;

	for(int i=2;i<N;i++){
		if(!sosu[i]){
			for(int j=2;j<=(N/i);j++){
				sosu[i*j]=true;
			}
		}
	}

}


int main(){
	
	sosuhyo();

	int a,count;

	while(cin>>a && a){
		count=0;
		for(int i=0;i<=a;i++){
			if(!sosu[i])count++;
		}
		cout << count << endl;
	}

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;


#define N_MAX 100000
int main(){
	
	int array[N_MAX],i,j,n, num = 0;
	
	while(cin>>n){
		num = 0;
		for (i=0;i<n;i++)
			array[i]=i+2;
		for (i=0;i<sqrt(n*1.0);i++){
			for (j = (i+2); (i+2) * j <= n; j++)
				array[(i+2) * j - 2] = -1;}

	for (i = 0; i < n-1; i++){
    if (array[i] != -1)
	num++;
	}
	cout<<num<<endl;
	}

	cin>>n;
	
	
	
	
  
	return (0);
}

C++: #include<iostream>
using namespace std;
int main(){
  int a,t[1000000],u[1000000];
  for(int i=0;i<1000000;i++){
    t[i]=1;
  }
  t[0]=t[1]=u[0]=u[1]=0;
  for(int i=2;i<=1000000;i++){
    if(t[i]==1){
      for(int j=i+i;j<1000000;j+=i)t[j]=0;
      u[i]=u[i-1]+1;
    }else{
      u[i]=u[i-1];
    }
  }
  while(cin>>a){
    cout<<u[a]<<endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

long n,ans;

int main(){
	while(cin >> n){
		ans = 1;
		if(n == 1){
			cout << 0 << endl;
			continue;
		}
		if(n == 2){
			cout << 1 << endl;
			continue;
		}
		for(long i=3;i<=n;i=i+2){
			ans += 1;
			for(long j=3;j*j<=i;j=j+2){
				long k = i/j;
				if(i == k*j){
					ans -= 1;
					break;
				}
			}
		}
		
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main() {
    int i, k, v,scan,an;
    int MAX_V = 999999;
    int count[MAX_V];
    int sum[MAX_V];
    int prime[MAX_V];
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1;
    }
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0;   
            } 
        }
    }
    count[0]=0;
    for(i=1;i<=MAX_V;i++){
        count[i]= count[i-1]+prime[i];
    }
    while(scanf("%d",&scan)!= EOF){
        an=count[scan]-count[0];
        printf("%d\n",an);
    }
    return 0; 
}

C++: #include<iostream>
#include<string>
#include<math.h>
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;
	int i, j;
	int flag;
	int count;
	while (cin >> n) {
		count = 4;
		if (n < 10) {
			if (n == 0 || n == 1) {
				cout << "0" << endl;
			}
			else if (n == 2) {
				cout << "1" << endl;
			}
			else if (n == 3 || n == 4) {
				cout << "2" << endl;
			}
			else if (n == 5 || n == 6) {
				cout << "3" << endl;
			}
			else if (n == 7 || n == 8 || n == 9) {
				cout << "4" << endl;
			}
		}else {
			for (i = 10; i <=n; i++) {
				flag = 0;

				for (j = 3; j < sqrt(i) + 1; j += 2) {
					if (i % 2 == 0 || i%j == 0) {
						flag = 1;
						break;
					}
				}
				if (flag == 0) {
					count++;
				}
			}
			cout << count << endl;
		}
	}
	return 0;
}