https://www.acmicpc.net/problem/4948
import math
while 1:
n=int(input())
if n==0: break
count=0
cnt=0
for i in range(n+1,2*n+1):
for j in range(2,int(i**(1/2))+1):
if i%j==0:
cnt=1
break
if cnt==0: count+=1
cnt=0
print(count)