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 := 2; j < i-1; j++ {
				if i%j == 0 && j != 1 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: //#define _GRIBCXX_DEBUG
#include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;


// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion


// Effective std
#pragma region ESTD
template<typename C, typename T>
constexpr int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F>
constexpr int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T, typename U>
constexpr void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U>
constexpr void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C>
constexpr void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred>
constexpr void sort(C& c, Pred p) { sort(ALL(c), p); }
template<typename C>
constexpr void reverse(C& c) { reverse(ALL(c)); }
#pragma endregion


// ?´???°
#pragma region PRIME
bool is_prime(unsigned n) {
  switch(n) {
    case 0:
    case 1: return false;
    case 2: return true;
  }
  if (n%2==0) return false;
  for (unsigned i=3; i*i<=n; i+=2)
    if (n%i==0) return false;
  return true;
}
#pragma endregion


// ??§??????/?°?????????????
#pragma region TRANSFORM
void mutal_tr(string &s) {
  for(int i=s.size(); i--;) {
    if(islower(s[i])) s[i] = toupper(s[i]);
    else if (isupper(s[i])) s[i] = tolower(s[i]);
  }
}
void to_upper(string &s) { for(int i=s.size(); i--;) s[i] = toupper(s[i]); }
void to_lower(string &s) { for(int i=s.size(); i--;) s[i] = tolower(s[i]); }
#pragma endregion


// ??????
#pragma region SET
template<class T>
set<T> intersection(const set<T>& sa, const set<T>& sb) {
  set<T> ret;
  for(T a : sa) if(sb.find(a) != sb.end()) ret.insert(a);
  return ret;
}
#pragma endregion

// Union Find
#pragma region UF
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) {}
  bool union_set(int x, int y) {
    x = root(x); y = root(y);
    if(x!=y) {
      if(data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool find_set(int x, int y) { return root(x) == root(y); }
  int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
  int size(int x) { return -data[root(x)]; }
};
#pragma endregion


// ?????°
#pragma region CONST_VAL
#define PI (2*acos(0.0))
#define EPS (1e-9)
#define MOD (int)(1e9+7)
#pragma endregion

int main()
{
    const int N = 1000000;
    vector<bool> prime(N,true);
    prime[0] = prime[1] = false;
    for(int i=2; i*i<N; ++i) {
        if(!prime[i]) continue;
        for(int j=i*i; j<N; j+=i) prime[j] = false;
    }
    vi ans(N);
    rep(i,N) ans[i] = ans[i-1] + prime[i];
    int n ;
    while(cin>>n) P(ans[n]);
    return 0;
}

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

int main(){

  int n;
  int a,b,i;
  int sosu[N];
  bool judge;

  sosu[0] = 2;
  for(a=3,i=1;a<1000000;a++){
    judge = true;
    for(b=0;sosu[b]*sosu[b] <= a;b++){
      if(a%sosu[b] == 0){
	judge = false;
	break;
      }
    }
    if(judge){
      sosu[i] = a;
      i++;
    }
  }
  sosu[i] = 1000000;
  while(cin >> n){
    if(0<n && n<1000000){
      for(i=0;sosu[i]<=n;i++);
      cout << i << endl;
    }
  }

  return 0;
}

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

using namespace std;

void Eratosthenes(vector<int> &S_List, vector<int> &P_List){
	while(1){
		vector<int>::iterator it = S_List.begin();
		P_List.push_back(*it);  //先頭を素数リストへ追加
		int num = *it;
		while (it != S_List.end()){
			if ((*it % num) == 0){
				it = S_List.erase(it); //探索リストから倍数を除外
			}
			else{
				++it;
			}
		}
		vector<int>::iterator P_it = max_element(P_List.begin(), P_List.end());
		double p_max_sqr = sqrt(*P_it);
		vector<int>::iterator S_it = max_element(S_List.begin(), S_List.end());
		if (S_List.empty() == true){
			return;
		}
		if (*S_it < p_max_sqr){
			return;
		}
		/*else{
			Eratosthenes(S_List, P_List);
		}*/
	}
}


void output(vector<int> ex){
	/*vector<int>::iterator it = ex.begin();
	while(it != ex.end()){
		cout << *it << endl;
		++it;
	}*/
	cout << ex.size() << endl;
}

int main(void){
	int num;
	while (cin >> num){
		vector<int> S_List, P_List;
		for (int i=2; i<=num; ++i){
			S_List.push_back(i);
		} 
		Eratosthenes(S_List, P_List);
		output(P_List);
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
int cnt,n,prime[1000000];
using namespace std;

void count()
{
	int tt=0,flag;
	prime[tt++]=2;
	for(int i=3;i<=n;i++)
	{
		flag=1;
		for(int j=0;prime[j]*prime[j]<=i;j++)
		{
			if(i%prime[j]==0)
			{	
			    flag=0;
		     	break;
			}
		}
		if(flag==1) prime[tt++]=i;
	}
	cout << tt << endl;
}

int main()
{
	while(true)
	{
	   cin >> n;
	   if(n==1){
	   	cout << 0 << endl;
	   	continue;
	   }
	   count();
    }
}

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 <iostream>
using namespace std;
int main()
{
	int prime[80000];
	int ptr=2;
	prime[0] = 2;
	prime[1] = 3;
	for(int num=5; num<1000000; num+=2){
		bool f = false;
		for(int i = 0; i<ptr; i++){
			if (prime[i]*prime[i] > num) break;
			if (num%prime[i]==0) {
				f = true;
				break;
			}
		}
		if(!f) prime[ptr++] = num;
	}
	prime[ptr]=1000001;
	int n;
	while(cin >> n){
		int k=0;
		for(;prime[k]<=n;k++);
		cout << k << endl;
	}
	
	return 0;
}

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

int main(){
  //bool num[MAX];
  pair<bool,int> num[MAX];
  int input=0;
  while( cin >> input){
   int count=0;
  for(int i=2; i<MAX; i++){
    num[i].first=true;
    num[i].second=i;
  }
  for(int i=2;i<input+1;i++){
    if(num[i].first){
      //cout << num[i].second <<",";
      count++;
      for(int j=i+i; j<MAX; j+=i){
        num[j].first=false;
      }
    }
  }
  cout << count << endl;
  }
}