def f(n) (3..(n**0.5).floor).each{|i| return i if n % i == 0 } end N = gets.to_i puts f(N)