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++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;
int sieve(int n);
int prime[1000000];
bool is_prime[1000000];

int main()
{

	int p = 0;
	for (int i = 0; i <= 999999; i++) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= 999999; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= 999999; j += i) {
				is_prime[j] = false;
			}
		}
	}
	while (true) {
		int n;
		cin >> n;
		int i = 0;
		while (prime[i] <= n) {
			i++;
		}
		cout << i << endl;
	}
}

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

bool Eratos[1000000];

int main()
{
	Eratos[0] = Eratos[1] = false;
	for (int i = 0; i < 1000000; i++){
		Eratos[i] = true;
	}
	for (int i = 2; i < 1000; i++) {
		if (Eratos[i]) {
			for (int j = 2 * i; j < 1000000; j += i) {
				Eratos[j] = false;
			}
		}
	}
	int n,res;
	res = 1;
	for (int i = 2; i < 1000000; i++) {
		if (Eratos[i])
			Eratos[i] = res;
		res++;
	}
	while (scanf("%d", &n)) {
		res = 0;
		while (!Eratos[n]) {
			n--;
		}
		printf("%d\n",Eratos[n]);
	}
	return 0;
}

C++: /*#include <cstdio>
#define MAX 1000

int main(){
	int n;
	bool c[MAX]={true};
	int t[MAX];t[0] = 0;
	for(int i = 2;i < MAX;i++){
		for(int j = i;i*j < MAX;j++){
			c[i*j-1] = true;
		}
	}
	for(int i = 1;i < MAX;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}
	while(scanf("%d", &n)){
		printf("%d\n", t[n-1]);
	}
	return 0;
}*/

#include <cstdio>

int main(){
	int n;
	static bool c[1000000]={true};
	static int t[1000000];t[0] = 0;
	for(int i = 2;i < 1000000;i++){
		if(!c[i]){
		for(int j = 2;i*j < 1000000;j++){
			c[i*j] = true;
		}
		}
		t[i]=t[i-1]+!c[i];
	}
	/*for(int i = 1;i < 1000000;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}*/
	for(int n;scanf("%d", &n);n++){
		printf("%d\n", t[n]);
	}
	
	while(scanf("%d", &n)){
		printf("%d\n", t[n+1]);
	}
	return 0;
}

/*#include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout<<npr[n]<<endl;
  }
  return 0;
}*/

C++: #include<stdio.h>
#include<math.h>
bool flag[1000000];
int main(void)
{
	long long i,j,p,n,count;
	p = (long long)sqrt(1000000.0);
	for(i = 3; i <= p; i = i + 2)
	{
		if(flag[i] == false)
		{
			for(j = i * i; j <= 1000000; j = j + 2 * i)
			{
				flag[j] = true;
				
			}
		}
	}
		
	while((scanf("%lld",&n)) != EOF)
	{
		
		if(n == 1 || n == 0)
			count = 0;
		else
		{
			count = 1;
			for(i = 3; i <= n; i = i + 2)
			{
				if(flag[i] == false)
					count++;
			}
		}
		printf("%lld\n",count);
	}
	

		
	return 0;
}

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

#define N 1000000L
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = 1000;
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == 1) count++;
    }
    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

C++: //Prime Number
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> v;

int main(){
  ll n;
  v.push_back(2);
  for(ll i=3; i<1000000; i+=2){
    bool flag=true;
    for(vector<int>::iterator it=v.begin(); it!=v.end() && (*it)*(*it)<=i; it++){
      if(i%(*it)==0){
        flag=false;
        break;
      }
    }
    if(flag)v.push_back(i);
  }
  while(scanf("%lld", &n)!=EOF){
    ll ans=0;
    for(vector<int>::iterator it=v.begin(); it!=v.end(); it++){
      if(*it>n)break;
      ans++;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

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

int isPrime(int n);

int main(){
  int n,out;
  while(cin >> n){
    out = 0;
    for(int i=2;i<=n;i++){
      if(isPrime(i)) out++;
    }
    cout << out << endl;
  }
  
}

int isPrime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0) return 0;
  }
  return 1;
}

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

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

int main(){
	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
			if(prime(i))++a;
	}
		cout << a << '\n';
	}
}

C++: /*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int prime(int a)
{
	if(a<2)
	return 1;
	
	for(int i=2 ; (i*i)<=a ; i++)
	{
		if(a%i==0)
		return 0;
	}
	
	return 1;
}

int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		int d=0;
		forin(i,2,a+1)
		{
			if(prime(i)==1)
			d++;
		}
		printf("%d\n",d);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	while(cin>>n){
		int cnt=0;
		vector<int> v(n+1,1);
		for(int i=2; i<=sqrt(n); i++){
			for(int j=i+1; j<=n;j++){
				if(v[i]==1){
					if(j%i==0)
						v[j]=0;
				}
			}
		}
		for(int i=2;i<=n;i++){
			if(v[i]==1)
				cnt++;
		}
		cout << cnt << endl;
	}
}