a=[0,0,0,0,3,0,5,0,7,7,7,0,11,0,13,7,7,0,8,0,19,19,7,0,23,23] x=input() if x<26:print a[x] else:print 14 if (x-1)%8==0 and x%2 and pow(2,x-9,x-8)==1 else 8