Write a program which reads an integer n and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5 and 7.
import math as m
n=int(input())
a=[0]*(n+1)
a[0],a[1]=1,1
for i in range(2,int(m.sqrt(n))+1):
	for j in range(2,int(n/i)+1):
		a[i*j]=1
print(a.count(0))
while True:
	try:
		n=int(input())
		a=[True]*(n+1)
		a[0]=a[1]=False
		for i in range(2,int(n**0.5)+1):
			if a[i]:
				for j in range(i**2,n+1,i):
					a[j]=False
		print(a.count(True))
	except:
		break