Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

int yakusuu(int i){
	int counter=0;
	for (int j = 1; j <= i; j++){
		if (i%j == 0) counter++;
	}
	return counter;
}


int main()
{
	int n;
	
		
		while (scanf("%d",&n)!=-1)
		{
			int counter1 = 0;
			for (int i = 0; i <= n; i++)
			{
				if (yakusuu(i) == 2) counter1++;
			}

				cout << counter1 << endl;
		}
		
		
	return 0;
}

C++: int primes[78498], num_primes;
int calculated;
int count_pos(int n) {
	for (int i = 0; i < num_primes; i++) {
		if (primes[i] == n) {
			return i + 1;
		}
		else if (primes[i] > n) {
			return i;
		}
	}
	return num_primes;
}
int main() {
	primes[0] = 2;
	calculated = 2;
	num_primes = 1;
	while (true) {
		int n;
		if (!scanf_s("%d", &n)) break;
		if (calculated+1 < n) {
			for (int i = calculated + 1; i < n + 1; i += 2) {
				bool is_prime = true;
				int max = (int)(sqrt(i)) + 1;
				for (int j=1; primes[j] < max&&j<num_primes; j++) {
					if (i%primes[j] == 0) {
						is_prime = false;
						break;
					}
				}
				if (is_prime) {
					primes[num_primes++] = i;
				}
			}
			calculated = n - (n % 2);
		}
		printf("%d\n", count_pos(n));
	}
}

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

int main(){

	bool pn[1000010];
	int sum[1000010] = {0};
	int n;
	
	for(int i = 0; i <= 1000000; i++) {
		pn[i] = true;
	}
	
	pn[1] = false;
	for(int i = 1; i <= 1000000; i++) {
		if(!pn[i]) continue;
		for(int j = 2; i*j <= 1000000; j++) {
			if(pn[i*j]) pn[i*j] = false;
		}
	}
	
	for(int i = 1; i <= 1000000; i++) {
		sum[i] = sum[i-1] + pn[i];
	}
	
	while(cin >> n) {
		cout << sum[n] << endl;
	}

    return 0;
}

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

int main()
{
	int n;
	while(cin >> n)
	{
		int i,j;
		int k = 0;
		for (i=2; i<=n; i++)
		{
			int c=0;
			for(j=1; j<=n; j++)
			{
				if(i%j == 0)
				{
					c++;
				}
			}
			if (c == 2)
			{
				k++;
			}
		}
		cout << k << endl;
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;
const int N = 1000000;
int main(){
	int n;
	vector<bool> v(N,true);
	v[0] = false;
	v[1] = false;
	for (int i=2; i<N; ++i){
		if (v[i] == true){
			for (int j=2*i; j<N; j+=i){
				v[j] = false;
			}
		}
	}
	vector<int> cnt(N);
	for (int i=2; i<N; ++i){
		if (v[i]) cnt[i] = cnt[i-1]+1;
	   else cnt[i] = cnt[i-1];
	}
	while (cin >> n){
		cout << cnt[n] << '\n';
	}
	return 0;
}

C++: #include<iostream>

using namespace std;

int main()
{
    int n,i,k,j,b=0;

    cin >> n;

     for(i=2; i<=n; i++)
    {
        k = 1;
        for(j=2; j<=i/2; j++)
        {
            if(i%j==0)
            {
                k = 0;
                break;
            }
        }

        if(k==1)
        {
            b++;
        }
    }

    cout << b << endl;

    return 0;
}

C++: #include<iostream>
int main() {

  int n,i,j,c;
  while(std::cin>>n){
    c=0;
    int list[n-1];
    for(i=2;i<n+1;i++)list[i-2]=i;
    for(j=2;j*j<n+2;j++)
      if(list[j-2]!=0)
	for(i=1;j-2+list[j-2]*i<n;i++)
	  list[j-2+list[j-2]*i]=0;
    for(i=0; i<n-1; i++)
      if(list[i]!=0)c++;

    std::cout<<c<<"\n";
  }
}

C++: #include <stdio.h>

int main(){
	long sosuu[] = { 2, 3, 5 }, i, x, y = 3,n=0,z,d=0;
	while (scanf("%d", &n) != EOF){
		z = 0;
		if(d < n)
		{for (i = 3; i < n; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0){ break; }
				if (x + 1 == y){ sosuu[y] = i, y++; d = i; }
			}
		}
	}
		for (i = 0; i < n; i++){ if (sosuu[i] > n + 1)break; z++; }printf("%d\n", z);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int i,n,k;
	
	while(cin >> n){
		int flug[n+1];
		int count = 0;
		for(i=0;i<n+1;i++) flug[i] = 1;
		// 0, 1は除外
		flug[0] = flug[1] = 0;
		for(i=2;i*i<n;i++){
			for(k=n;k>=2;k--){
				if((k % i == 0) && (k != i)){
					flug[k] = 0;
				}
			}
		}
		
		// 個数を走査
		for(i=2;i<n+1;i++){
			if(flug[i] == 1){
				count++;
			}
		}
		
		cout << count << endl;
	}
	return 0;
}

C++: while True:
	try:
		n=int(input())
		a=[True]*(n+1)
		a[0]=a[1]=False
		for i in range(2,int(n**0.5)+1):
			if a[i]:
				for j in range(i**2,n+1,i):
					a[j]=False
		print(a.count(True))
	except:
		break

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

using namespace std;

int MAX = 9;

vector <int> v;

int main() {
	int n;
	
	while (cin>>n) {
		v.clear();
		
		for (int i=0; i<=MAX; i++) v.push_back(n-i);
		sort(v.begin(), v.end());
		
		int ans = 0;
		
		for (int i=0; i<=MAX; i++) {
			for (int j=0; j<=MAX; j++) {
				for (int k=0; k<=MAX; k++) {
					if (binary_search(v.begin(), v.end(), i+j+k)) ans++;
				}
			}
		}
		cout << ans << endl;
	}
	
	return 0;
}

C++: #include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	int n;
	int count = 1;
	if (n == 1) {
		cout << 0 << endl;
	}
	else if (n == 2) {
		cout << 1 << endl;
	}
	else {
		for (int t = 3; t <= n - 1; t += 2) {
			FOR(i, 1, t - 1) {
				if (t%i == 0) {
					break;
				}
				if (i == t - 1) {
					count++;
					break;
				}
			}
		}
		cout << count << endl;
	}
	
	return 0;
}

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

bool isPrime(int x) {
  if(x == 2) {
	return true;
  }
  else if(x < 2 || x % 2 == 0) {
	return false;
  }
  else {
	for(int i = 3; i <= (int)sqrt(x); i += 2) {
	  if(x % i == 0) {
		return false;
	  }
	}
  }
  return true;
}

int main() {
  int n;
  bool a[1000000];

  for(int i = 1; i < 1000000; ++i) {
	if(isPrime(i)) {
	  a[i] = true;
	}
  }
  
  while(cin >> n) {
	cout << accumulate(&a[1], &a[n+1], 0) << endl;
  }
  return 0;
}

/*-- primitive algorithm --*/
/*
bool isPrime(int n) {
  for(int i = 2; i < n; ++i) {
	if(n % i == 0) return false;
  }
  return true;
}
*/

C++: #include<iostream>
#include<stdio.h>
using namespace std;
typedef long long ll;
const ll MAX=1e6;
ll prime[MAX+2],mark[MAX+2],ans[MAX+2];
void Prime(){
    memset(mark,0,sizeof(mark));
    ll index=0;
    for(ll i=2;i<=MAX;i++){
        if(mark[i]) continue;
        else{
            prime[++index]=i;
            for(ll j=i*i;j<=MAX;j+=i){
                mark[j]=1;
            }
        }
    }
}
int main(){
    ll a;
    memset(ans,0,sizeof(ans));
    Prime();
    for(int i=2;i<=MAX-2;i++){
        if(mark[i]==0) ans[i]=ans[i-1]+1;
        else ans[i]=ans[i-1];
    }
    while(scanf("%I64d",&a)!=EOF){
        cout<<ans[a]<<endl;;
    }
    return 0;
}