N=gets.to_i (1..1/0.0).each{|w| if w.step(N,w).all?{|e|e.prime?} and (N/w*w+1..N).all?{|e|e.prime?} p w exit end }