Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 2; i <= num; i++ { //1を除く入力値以下の数字
			for j := i - 1; j >= 1; j-- {
				if i%j == 0 && j != 1 {
					flag = true
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//?????§??¬?´???°??¨????°???¬?????°
//O(1)?????????
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

#define NUM_MAX   10000000
bool flag[NUM_MAX];
vector< int >prm;

int N;
int ans = 0;
int K;

void eratosthenes(){
	if( N < 2 ) return;
	fill( flag, flag+NUM_MAX, 0 );
	int idx = 2;
	while( idx <= K ){
		while( flag[idx] ) idx++;
		if( idx > N ) break;
		prm.push_back( idx );
		for( int i = idx; i <= N; i += idx ) flag[i] = 1;
		ans++;
	}
	while( idx < N ){
		idx++;
		if( !flag[idx] ){
			prm.push_back( idx );
			ans++;
		}
	}
}


int main(){
	
	while( cin>>N, N != EOF ){
		K = sqrt( N );
		K++;
		
		eratosthenes();
		
		cout<<ans<<endl;
		/*
		REP( i, prm.size() ){
			cout<<prm[i]<<endl;
		}*/
		prm.clear();
		ans = 0;
	}	
	return 0;
	
}

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

int main(){

  int n;
  int a,b,i;
  bool count[1000000];
  count[2] = true;
  for(a=3;a<1000000;a++){
    i = 0;
    if(a%2!=0){
      for(b=3,i=1;b<=a/3;b++){
	if(b%2!=0){
	  if(a%b == 0){
	    i = 0;
	    break;
	  }
	}
      }
    }
    if(i)
      count[a] = true;
    else
      count[a] = false;
  }

  while(cin >> n){
    for(a=2,b=0;a<n;a++)
      if(count[a] == true)
	b++;
    cout << b << endl;
  }
  return 0;
}

C++: #include<bits//stdc++.h>
using namespace std;
int main(){
	int a[1000000];
	a[0]=2;
	int z=1;
	for(int i=2;i<100000;){
		for(int j=0;j<z;j++){
			if(i%a[j]==0)goto stop;
		}
		a[z]=i;
		z++;
		stop:;
		if(i==2) i++;
		else i+=2;
	}
	int b;
	while(cin>>b){
		int c=0;
		for(int i=0;i<z;i++){
			if(a[i]>b)break;
			else c++;
		}
		cout<<c;
	}
}

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

int main() {
	int n, ans; bool not_prime[1000000 + 1];
	not_prime[0] = true;
	not_prime[1] = true;
	for (int i = 2; i <= sqrt(1000000); i++) {
		if (!not_prime[i]) {
			for (int j = i * 2; j <= 1000000; j += i) {
				not_prime[j] = true;
			}
		}
	}
	for (int i = 0; i < 1000000 + 1; i++) {
		if (!not_prime[i]) { not_prime[i] = false; }
	}
	while (cin >> n) {
		ans = 0;
		for (int i = 2; i <= n; i++) {
			if (not_prime[i] == false) { ans++; }
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <stdio.h>
using namespace std;
int isprime(int x){
    if(x==2||x==3) return true;
    if(x<5||x%2==0||x%3==0) return false;
    else{
        int i=5;
        while(i<=sqrt(x)){
            if(x%i==0) return false;
            i = i+2;
        }
        return true;
    }
}
int main() {
    int n;
    while(cin >> n){
        int ans=0;
        int i=2;
        while(n-i){
            if (isprime(i)) {
                ans++;
            }
            i++;
        }
        
    cout << ans << endl;
    }
}

C++: #include<iostream>

using namespace std;

int main() {
    int n = 999999;
    char* p;
    int t = 2;

   

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

    for(int i = 2; i < n; i++) {
        if(p[i] == 0)
            continue;
        for(int point = i * 2; point < n; point += i) {
            p[point] = 0;        
        }
    }
    
    while(cin >> n) {
        int c = 0;
        for(int i = 1; i <= n; i++) {
            if(p[i]) {
                c++;
            }
        }
        cout  << c << endl;
    }



    return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;

bool isPrime(int num) {
	if (num == 1)return false;
	if (num == 2)return true;


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


int main() {

	int num;
	int count;
	while (cin >> num) {
		count = 0;
		for (int i = 1; i <= num; i++) {
			if (isPrime(i))count++;
		}
		printf("%d\n", count);

	}

	//system("pause");
	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<iostream>
using namespace std;
int main(){
	int a,n,i,j;
	cin>>a;
	n=0;
	for(i=2;i<=a;i++){
		for(j=2;j<i;j++){
			if(i%j==0)break;
		}
		if(i == j) n += 1;
	}
	cout<<n<<endl;
}

C++: #include <iostream>

int prime_number_count(const int n)
{
    int cnt;
    bool was_not_divisible;
    
    if (n < 2){
        return 0;
    }
    
    cnt = 1;
    for (int i = 3; i <= n; i += 2){  // dividend: 被除数
        was_not_divisible = true;
        for (int j = 3; j * j <= i; j += 2){  // divisor: 除数
            if (i % j == 0){
                was_not_divisible = false;
                break;
            }
        }
        if (was_not_divisible){
            cnt++;
        }
    }
    
    return cnt;
}

int main()
{
    int n;
    
    while (std::cin >> n){
        std::cout << prime_number_count(n) << std::endl;
    }
    
    return 0;
}

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

int main() {
	int n, count;
	bool a[MAX];
	for (int i = 2;i < MAX;i++) { a[i] = true; }
	for (int i = 2;i < sqrt(MAX);i++) {
		if (a[i] ==true) {
			for (int j = 2;j*i < MAX;j++) { a[j*i] = false; }
		}
	}
	
	while (cin >> n) {
		count = 0;
		for (int i = 2;i <= n;i++) {
			if (a[i])
				count++;
		}
		cout << count << endl;
	}
}