require 'prime' p_div = Prime.prime_division(gets.to_i) ans = p_div[0][0] if ans == 2 ans = p_div[1][0] end p ans