isComposite 1 = False
isComposite n = or [n`mod`x==0|x<-[2..n-1]]
main=do
    n<-getLine>>=return.(read::String->Integer)
    print$head$[x|x<-[n-100..n+100], isComposite x]