Go: package main

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

func main() {
	b2i := func(b bool) int {
		if b {
			return 1
		}
		return 0
	}

	prime := func(n int) []int {
		ans := make([]int, n+1)
		for i := 2; i <= n; i++ {
			b := ans[i] == 0
			ans[i] = ans[i-1] + b2i(b)
			if b {
				for j := i * 2; j <= n; j += i {
					ans[j] = 1
				}
			}
		}
		return ans
	}
	reader := bufio.NewScanner(os.Stdin)
	primeT:=prime(999999)
	for reader.Scan() {
		n, _ := strconv.Atoi(reader.Text())
		fmt.Println(primeT[n])
	}
}

C++: #include <iostream>
#define Even(n) n%2
using namespace std;

void count_Prime(int n);
int Euclid(int n, int m);


int main()
{
	int Data;

	while (cin >> Data)
	{
		count_Prime(Data);
	}

	return 0;
}

void count_Prime(int n)
{
	int counter = 0, euclid = 0, i = 0, j = 0;
	for (i = 2; i <= n; ++i)
	{
		if (Even(i) != 0 || i == 2)
		{
			for (j = 2; j <= i; ++j)
			{
				euclid = Euclid(j, i);
				if (euclid == i)
					counter++;     // ????????????????????§??????
				else if (euclid != 1)               // ?????????????????¨??????Break????¨????????????\
					break;
			}
		}
	}

	cout << counter << endl;

}

int Euclid(int n, int m)
{
	//if (m % n == 0)
	//	return n;
	//else
	//	return Euclid(m%n, n);
	int r = m % n;

	while (r != 0)
	{
		m = n;
		n = r;
		r = m % n;
	}

	return n;
}

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

int main()
{
	int n, i, k, j, h;
	bool flag = false;

	for(i=0; i<30; i++)
	{
		cin >> n;
		h = 0;
		for(k = 2; k <= n; k++)
		{
			flag = false;
			for(j = 2; j < k; j++)
			{
				if(k % j == 0)
				{
					flag = true;
					break;
				}
			}
			if(flag == false)
				h++;
		}
		cout << h << endl;
	}
}

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

int main(){
    int n;
    int count=0;
   
    
    cin>>n;
           for(int a=1;a<=n;a++)
           {
            if(n%a==0)
           
            count=count+1;
                        }
             
    
    cout<<count;
    
    
}

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

bool prime(int n) {
	for(int i=2;i<=sqrt(n);++i) {
		if(n%i==0) { return false; }
	}
	return true;
}	

int main() {
	int n;
	while(scanf("%d",&n) != EOF) {
		vector<int> P;
		for(int i=2;i<=n;++i) {
			if(prime(i)) { P.push_back(i); }
		}
		printf("%d\n",(int)P.size());
	}
	return 0;
}

C++: #include<iostream>
#include<sstream>
#include<cstdio>
#include<fstream>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
using namespace std;
#define N 1000002
bool is_prime(int n){
	if(n<=1)return false;
	if(n==2)return true;
	if(!(n&1))return false;
	for(int x=3;x<=sqrt(n);x+=2) if(!(n%x))return false;
	return true;
}

int main(){
	int n;
	int primes[N];
	primes[0] = primes[1] = 0;
	int cnt = 1;
	primes[2] = cnt;
	for(int x=3;x<=N;++x){
		if(is_prime(x)){
			++cnt;
		}
		primes[x] = cnt;
	}
	while(scanf("%d",&n)==1){
		cout<<primes[n]<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

bool p[1000001];
int pn[1000001];

int main()
{
    for(int i = 0; i < 1000001; i++)
    {
        p[i] = true;
    }
    for(int i = 2; i <= 1000000;i++)
    {
        if(!p[i])
            continue;
        for(int j = 2; i*j <= 1000000; j++)
        {
            p[i*j] = false;

        }
    }
    int result = 0;
    for(int i = 2; i < 1000001; i++)
    {

        if(p[i])
        {
            result++;
        }
        pn[i] = result;
    }
    int n;
    while(cin >> n)
    {
        cout << pn[n]<< endl;
    }
}

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

int main() {
	const int MAX_V = 100000;
	int prime[MAX_V+1];
	int i, k, 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;
			}
		}
	}
	scanf("%d", &v);
	int count = 0;
	for(i=0;i<=v;i++){
		int isprime = prime[i];
		if(isprime) count ++;
	}
	printf("%d",count);
	return 0;
}

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

using namespace std;

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

	while(cin >> n){
		cnt = 1;

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

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

			cnt++;
		}

		printf("%d\n",cnt);
	}

	return 0;
}

C++: #include <iostream>

const bool isPrime(const int p)
{
    if(p == 2)
    {
        return true;
    }

    if(p < 2 || p % 2 == 0)
    {
        return false;
    }

    for(int i = 3; i <= sqrt(p); i += 2)
    {
        if(p % i == 0)
        {
            return false;
        }
    }

    return true;
}

int main(void)
{
    bool p[1000000];

    for(int i = 0; i < 1000000; ++i)
    {
        p[i] = isPrime(i);
    }

    int n;

    while(std::cin >> n)
    {
        int result = 0;

        for(int i = 0; i <= n; ++i)
        {
            result += p[i];
        }

        std::cout << result << std::endl;
    }

    return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
//#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
const int maxn = 1e6;

bool vis[maxn];
vector<int> Prms(maxn);

void seive(int n) //sqrt(n)
{
    int m = sqrt(n+0.5);
    for(int i = 2; i <= m; i++){
        if(!vis[i])
        for(int j = i*i; j <= n; j += i){
            vis[j] = true;
        }
    }
    Prms.clear();
    for(int i = 2; i <= n; i++)
        if(!vis[i])
        Prms.push_back(i);
}

//#define LOCAL
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    seive(maxn);
    int n;
    while(~scanf("%d",&n)){
        int ans = upper_bound(Prms.begin(),Prms.end(),n)-Prms.begin();
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4??????
//int dy[]={0, 1, 0, -1};
//int dx[]={1, 0, -1, 0};

//8??????
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

int mm = 1000000;
vector<bool> d(mm);

void hoge(){
    d[0] = d[1] = true;
    FOR(i,2,mm){
        if(d[i]) continue;
        for(int j = 2; i*j <= mm; j++){
            d[i*j] = true;
        }
    }
}

void solve() {
    vector<int> dp(mm,INF);
    int val;
    int m = 2;
    dp[0] = dp[1] = 0;
    hoge();
    while(cin >> val){
        if(dp[val] == INF){
            FOR(i,m,val+1){
                dp[i] = dp[i-1] + (!d[i] ? 1 : 0);
            }
            m = val;
        }
        cout << dp[val] << endl;
    }
}

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

    solve();

    return 0;
}