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++: #include <cstdio>
#include <cstring>

using namespace std;

bool is_prime[1000000];
int prime[1000000];

void init_prime()
{
	int n = sizeof(prime)/sizeof(prime[0]);
	int i;

	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	prime[0] = prime[1] = 0;
	for (i=2; i<n; i++) {
		prime[i] = prime[i-1];
		if (is_prime[i]) {
			prime[i]++;
			int j;
			for (j=i+i; j<n; j+=i)
				is_prime[j] = false;

		}
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);

	init_prime();
	int a;

	while (scanf("%d", &a)==1) {
		printf("%d\n", prime[a]);

	}

	return 0;
}

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

int main()
{
	vector<int> prime,count;
	int j, k, x, num;
	while (cin >> num){
		prime.push_back(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.push_back(x);
				k++;
			}
		}
		count.push_back(prime.size() - 1);
		prime.clear();
	}
	for (int i = 0; i < count.size(); i++)
	{
		cout << count[i] << endl;
	}
	return 0;
}

C++: #include <deque>
#include <algorithm>
#include <iostream>
#include <functional>
using namespace std;
int main(){
	int N,t,f,ans=0,s;
	while(cin>>N){
	for(int j=0;j<N;j++){
		int cnt=0;
		for(int k=2;k<N;k++){
				if(N%k==0){
				cnt=1; 
			}
		}
		if(data[j]==2){
				cnt=0;
			}
		else if(data[j]==1){
				cnt=1;
			}
		if(cnt==0)ans++;
	}
 
cout<<ans<<endl;
}
return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<cmath>

using namespace std;

int main()
{
    int num;
    while(scanf("%d",&num)<=30){

            int a,b;
            int cot=0;
            for(a=2;a<=num;a++){

                b=0;
                for(int i=2;i<=sqrt(a);i++){
                    if(a%i==0){
                    b=1;
                    break;
                    }
                }
                if(b==0)
                cot++;
            }
            cout << cot << endl;
    }
    return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<math.h>
#define range 1000000
int total_added = 4;
struct primes{
	 int  key;
	 int  counts;
};
primes p[range];
bool is_prime(int key)
{
	int i;
	for (i = 2; i <= sqrt(key); i++)
	{
		if (key%i == 0)return false;
	}
	return true;
}
void init()
{
	p[0].key = 2;
	p[0].counts = 1;
	p[1].key = 3;
	p[1].counts = 2;
	p[2].key = 5;
	p[2].counts = 3;
	p[3].key = 7;
	p[3].counts = 4;
	int i;
	for (i = 8; i <= range; i++)
	{
		if (i % 2 != 0&&i%3!=0&&i%5!=0)
		{
			if (is_prime(i))
			{
				p[total_added].key = i;
				p[total_added].counts = p[total_added - 1].counts + 1;
				total_added++;
			}
		}
	}
}
int counting_result(int key)
{
	for (int i =total_added-1; i>=0; i--)
	{
		if (key >= p[i].key)
			return p[i].counts;
	}
	return 0;
}

int main()
{
	init();
	int i=0, n;
	while (scanf("%d", &n)==1&&30)
	{
		
		printf("%d\n",counting_result(n));
		i++;
	}

}

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

using namespace std;


int main(){
	int ans=0;
	int n,flag=0;

	while(cin >> n){
		for(int number=2;number<=n;number++){
			for(int i=2;i<number;++i ) {
	    		if( number%i==0 ) {
	      			flag = 1;
	      			break;
	    		}
	  		}
			if(flag==0)ans++;
			flag=0;
		}
		printf("%d\n",ans);
		ans = 0;
	}


	return 0;
}

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

using namespace std;

int main(){
	int n,i,j,buf,cnt;
	bool flag;

	while(cin >> n){
		if(n == 1){
			cout << "0" << endl;
			continue;
		}

		cnt = 1;

		for(i=3;i<=n;i+=2){
			flag = false;
			buf = (int)sqrt((double)i);

			for(j=3;j<=buf;j+=2){
				if((i % j) == 0){
					flag = true;
					break;
				}
			}

			if(flag == false){
				cnt++;
			}
		}

		cout << cnt << endl;
	}

	return 0;
}

C++: /*#include"iostream"
#include"stdio.h"
#include"string.h"
using namespace std;
long kt( string a)
{
	long d=0, d1=0;
	long n=a.size();
	if(97<=a[0]&&a[0]<=122)
	{
			for(long i=1;i<n;i++)
			if(65<=a[i]&&a[i]<=90)
			d++;
	}
	
	for(long i=0;i<n;i++)
	{
		if(65<=a[i]&&a[i]<=90)
		d1++;
	}
	if(d1==n) return 2;
	if(d==n-1) return 1;
	return 0;
}
long main()
{
	
	string a;
	cin>>a;
	long n=a.size();
	if(kt(a)==2)
	{
		for(long i=0;i<n;i++)
		a[i]+=32;
		cout<<a;
		return 0;
	}
	if(kt(a)==1)
	{
		for(long i=1;i<n;i++)
		a[i]+=32;
		a[0]-=32;
		cout<<a;
		return 0;
	}
	else cout<<a;
}
*/

#include <iostream>
using namespace std;

#define long long long
const long N = 10000000;
bool np[N];
long p[N], pp=0;

void eratos() {
    np[0]=np[1]=true;
    for (long i=2; i*i<N; i++) if (!np[i])
        for (long j=i*i; j<N; j+=i) np[j]=true;
    for (int i=2; i<N; i++)
    if (!np[i]) p[++pp]=i;
}
main()
{
	eratos();
	long n,d=0;
do
{
     d=0;
	cin>>n;
	
	for(long i=1;i<=n;i++)
	if(p[i]>n)
	{cout<<i-1<<endl; 
	break;}
}while(1);
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x3f3f3f3f
#define inff -30000000
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1000000+10;
bool notprime[MAX];
int num=0;
void init(){
    memset(notprime,0,sizeof(notprime));
    for(int i=2;i*i<=MAX;i++){
        if(!notprime[i]){
            for(int j=i*i;j<=MAX;j+=i)
                notprime[j]=1;
        }
    }
}
int main(){
    #ifdef SIYU
    freopen("in.txt","r",stdin);
    #endif // SIYU
    int n;
    init();
    while(cin>>n){
        //int *p=upper_bound(prime,prime+num,n);
        //int ans=p-prime;
        //cout<<ans<<endl;
        int ans=0;
        for(int i=2;i<=n;i++){
            if(!notprime[i])
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

C++: #include<stdio.h>
#define N 1000010

int main() {
	int ipt;
	int root;
	int cnt = 0;
	int A[N];
	for (int i = 1; i <= N; i++) {
		A[i] = i;
	}
	for (int pos = 2; pos <= N; pos++) {
		root = A[pos];
		if (!root)continue;
		for (int k = 2; k*root <= N; k++) {
			A[k*root] = 0;
		}
	}

	for (int P = 0; P < 30;P++) {
		scanf("%d", &ipt);
		for (int i = 2; i <= ipt; i++) {
			if (A[i] != 0)cnt++;
		}
		printf("%d\n", cnt);
		cnt = 0;
	}

	return 0;
}

C++: #include<stdio.h>
#include<math.h>
int gurobal[100000001]={0};
int main(void)
{
	int n=0;
	int i=0,j=0;
	int heihoukon=0;
	int count=0;
	while(scanf("%d",&n)!=EOF)
	{
		count=0;
		gurobal[1]=0;
		for (i=2;i<=n;i++)
		{
			gurobal[i]=1;
		}
		(int)heihoukon=sqrt((double)n);
		for (i=2;i<=heihoukon;i++)
		{
			if (gurobal[i]!=0)
			{
				for (j=i*2;j<=n;j+=i)
				{
					gurobal[j]=0;
				}
			}
		}
		for (i=2;i<=n;i++)
		{
			if (gurobal[i]!=0)
			{
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

C++: #include<cstdio>
const int maxn = 1000010;
int prime[maxn + 10];
int main(){
	for(int i = 2; i <= maxn; i++){
		if(!prime[i]) prime[++prime[0]] = i;
		for(int j = 1; j <= prime[0] && prime[j] <= maxn / i; j++){
			prime[prime[j] * i] = true;
			if(i % prime[j] == 0) break;
		}
	}
	int n;
	while(scanf("%d", &n) == 1){
		int l = 0, r = prime[0] + 1;
		while(r - l > 1){
			int m = (l + r) / 2;
			if(prime[m] <= n) l = m;
			else r = m;
		}
		printf("%d\n", l);
	}
	return 0;
}