n = gets.chomp.to_i res = n % 2 == 0 ? n/2 : n for i in 3..Math.sqrt(n)+2 do if n % i == 0 res = i break end end puts res