import sys

m=166666;a=[[1]*m for _ in[0]*2]

for i in range(m):

 if a[0][i]:

  k=6*i+5

  a[0][i+k::k]=[0]*len(a[0][i+k::k])

  a[1][-2-i+k::k]=[0]*len(a[1][-2-i+k::k])

 if a[1][i]:

  k=6*i+7

  a[0][-2-i+k::k]=[0]*len(a[0][-2-i+k::k])

  a[1][i+k::k]=[0]*len(a[1][i+k::k])

for e in map(int,sys.stdin):

 print(([e-1,sum(a[0][:(e+1)//6]+a[1][:(e-1)//6])+2][e>3]))

import sys

m=166666;s=[1]*m;t=[1]*m

for i in range(m):

 if s[i]:

  k=6*i+5

  s[i+k::k]=[0]*len(s[i+k::k])

  t[-2-i+k::k]=[0]*len(t[-2-i+k::k])

 if t[i]:

  k=6*i+7

  s[-2-i+k::k]=[0]*len(s[-2-i+k::k])

  t[i+k::k]=[0]*len(t[i+k::k])

for e in map(int,sys.stdin):

 print(([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3]))

import sys

m = 166666
a = [[1] * m for _ in [0] * 2]
for i in range(m):
    if a[0][i]:
        k = 6 * i + 5
        a[0][i + k :: k] = [0] * len(a[0][i + k :: k])
        a[1][-2 - i + k :: k] = [0] * len(a[1][-2 - i + k :: k])
    if a[1][i]:
        k = 6 * i + 7
        a[0][-2 - i + k :: k] = [0] * len(a[0][-2 - i + k :: k])
        a[1][i + k :: k] = [0] * len(a[1][i + k :: k])
for e in map(int, sys.stdin):
    print(([e - 1, sum(a[0][: (e + 1) // 6] + a[1][: (e - 1) // 6]) + 2][e > 3]))

import sys

m = 166666
s = [1] * m
t = [1] * m
for i in range(m):
    if s[i]:
        k = 6 * i + 5
        s[i + k :: k] = [0] * len(s[i + k :: k])
        t[-2 - i + k :: k] = [0] * len(t[-2 - i + k :: k])
    if t[i]:
        k = 6 * i + 7
        s[-2 - i + k :: k] = [0] * len(s[-2 - i + k :: k])
        t[i + k :: k] = [0] * len(t[i + k :: k])
for e in map(int, sys.stdin):
    print(([e - 1, sum(s[: (e + 1) // 6]) + sum(t[: (e - 1) // 6]) + 2][e > 3]))

-a = [[1] * m for _ in [0] * 2] +s = [1] * m +t = [1] * m -    if a[0][i]: +    if s[i]: -        a[0][i + k :: k] = [0] * len(a[0][i + k :: k]) -        a[1][-2 - i + k :: k] = [0] * len(a[1][-2 - i + k :: k]) -    if a[1][i]: +        s[i + k :: k] = [0] * len(s[i + k :: k]) +        t[-2 - i + k :: k] = [0] * len(t[-2 - i + k :: k]) +    if t[i]: -        a[0][-2 - i + k :: k] = [0] * len(a[0][-2 - i + k :: k]) -        a[1][i + k :: k] = [0] * len(a[1][i + k :: k]) +        s[-2 - i + k :: k] = [0] * len(s[-2 - i + k :: k]) +        t[i + k :: k] = [0] * len(t[i + k :: k]) -    print(([e - 1, sum(a[0][: (e + 1) // 6] + a[1][: (e - 1) // 6]) + 2][e > 3])) +    print(([e - 1, sum(s[: (e + 1) // 6]) + sum(t[: (e - 1) // 6]) + 2][e > 3]))