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 <iostream>
#include <string>
using namespace std;

int main(void)
{
	int number = 0;
	int count = 0;

	while(cin >>  number){
		count = 0;
		for(int i=2;i<=number;i++){
			for(int j= 2 ;j<=i/2;j++){
				if(i % j == 0){//割り切れる＝素数じゃない
					goto go;
				}
			}
			count++;
go:
		;
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include<stdio.h>

int prime(int n);
int main(){
	int count=0;
	int n;
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",prime(n));
	}
	return 0;
}

int prime(int n){
	int i,j;
	int p=0;
	int count=0;
	for(i=2;i<=n;i++){
		for(j=2;j<i;j++){
			if(i%j==0)p++;
		}
		if(p==0)count++;
		p=0;
	}
	return count;
}

C++: #include<stdio.h>
#include<math.h>
int isprime(int x){
	int i=3;
	while( i <= sqrt(x) ){
		if(x%i==0)return 0;
		i = i + 2;
	}
	return 1;
}
int main(){
	int n,c,i;
	while(scanf("%d",&n)!=EOF){
		c=1;
		for(i=3;i<=n;i+=2)if(isprime(i))c++;
		printf("%d\n",c);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>

using namespace std;

int n;
bool prime[1000000];

int main() {

	for (int i = 2; i <= 1000000; i++) prime[i] = true;

	for (int i = 2; i <= 1000000; i++) {
		if (!prime[i]) continue;
		for (int j = 2; i * j <= 1000000; j++) {
			prime[i * j] = false;
		}
	}

	n = -1;
	cin >> n;

	while (n != -1) {
		int cnt = 0;
		for (int i = 2; i <= n; i++) {
			if (prime[i]) cnt++;
		}
		cout << cnt << endl;

		n = -1;
		cin >> n;
	}

	return 0;
}

/*@@@@@@@@@@@@@@@@@@@@@@@@@*/
/*@                       @*/
/*@ debug output erased ? @*/
/*@                       @*/
/*@@@@@@@@@@@@@@@@@@@@@@@@@*/

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

int main() {
	int n, c;

	while (std::cin >> n) {
		std::vector<int> nums;
		++n;
		c = 0;
		for (int i = 0; i < n; ++i) {
			nums.push_back(i);
		}
		for (int i = 0; i < n; ++i) {
			if (nums.at(i) < 2) continue;
			for (int j = nums.at(i) * 2; j < n; j += nums.at(i)) {
				nums.at(j) = 0;
			}
		}
		for (int i = 0; i < n; ++i) {
			if (nums.at(i) > 1) {
				++c;
			}
		}
		std::cout << c << std::endl;
	}
	return 0;
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
/*int main(){
    
    ll n;
    while (cin>>n) {
        vector<ll> v;
        for(int i=0;i<n+1;i++){
            v.push_back(i);
        }
        ll b=v[v.size()-1];
        for(int i=2;i<=n;i++){
            ll j=2;
            while(i*j<=b){
                v[i*j]=0;
                j++;
            }
        }
        ll ans=0;
        for(int i=0;i<v.size();i++){
           // cout<<v[i]<<endl;
            if(v[i]!=0)ans++;
        }
        cout<<ans-1<<endl;
    }
    
    
    return 0;
}*/
int main(){
    
    ll n;
    while(cin>>n){
       /* ll ans=0;
        for(int i=3;i<=n;i+=2){
            int flag=0;
        for(int j=3;j<=sqrt(i);j+=2){
            if(i%j==0){
                flag=1;
                break;
            }
        }
            if(flag==0){
                ans++;
            }
    }
        cout<<ans+1<<endl;*/
        
        vector<bool> IsPrime;
        if(n+1>IsPrime.size()){
            IsPrime.resize(n+1,true);
        }
        IsPrime[0]=false;
        IsPrime[1]=false;
        for(int i=2;i<=sqrt(n);i++){
            if(IsPrime[I]){
                for(ll j=2;i*j<=n;++j){
                    IsPrime[i*j]=false;
}
        }
        
        }
        ll ans=0;
        for(int i=0;i<IsPrime.size();i++){
            if(IsPrime[i])ans++;
        }
        cout<<ans<<endl;
        }
    
    return 0;
}

C++: #include<stdio.h>
#include<float.h>
#include<vector>



int makePrimenumbers(int a){
	int temp;
	
	if(a<ref_max)return 0;

	temp = ref_max;
	ref_max=a;
	int i,k,isp=1;

	for(k=temp;k<ref_max;k++){
		for(i=0;i<primes.size();i++){
			if(k%primes[i]==0){
				isp=0;
				break;
			}
		}
		if(isp==1){
			primes.push_back(k);
		}
		isp=1;
	}
	return 0;
}

int countprime(int a){
	int i;
	for(i=0;i<prime.size();i++)
		if(a<prime[i])
			break;
	return (i);
}

int main(void)
{
	vector<int> primes;
	int ref_max=2;
	int result;
	int a;
	while(scanf("%d",&a)!=EOF){
		makePrimenumbers(a);
		result = countprime(a);
		printf("%d\n",result);
	}
  return 0;
}

C++: #include <stdio.h>
 #include <string.h>
int main(void) {
    int n,i,c,k,prime[999999] = {0},t;
    for(i = 2; 999999 >= i; i++){
        if(!prime[i])
    		for(c = i*2; 999999 >= c; c += i)prime[c] = 1;
    }
    while(scanf("%d",&n) != EOF){
    	i = 0;
    for(c = 2; n > c; c++){
        	if(!prime[c]) i++;
        }
    printf("%d\n",i);
    }
     
    return 0;
}

C++: #include<cstdio>
int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int x=0;
        for(int j=2;j<=n;j+=2){
            bool a=true;
            for(int i=3;i*i<n;i+=2){
                if(j==3)break;
                if(j%i==0){
                    a=false;
                    break;
                }
            }
            if(a)x++;
            if(j==2)j--;
        }

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

    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vi prime_count;
void sieve(int max){
    int count = 0;
    vector<bool> table(max + 1, true);
    table[0] = false;
    prime_count.push_back(0);
    table[1] = false;
    prime_count.push_back(0);
    for(int i = 2; i <= max; i++){
        if(table[i]){
            count++;
            for(int j = 2; i * j <= max; j++){
                table[i * j] = false;
            }
        }
        prime_count.push_back(count);
    }
}

int main(){
    int n;
    sieve(10000);
    while(cin>>n){
        cout << prime_count[n] << endl;
    }
    return 0;
}

C++: #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);
}