n = gets.to_i nh = Math.sqrt(n).to_i x = 0 3.upto(nh) do |y| x = y if n % x == 0 puts x exit end end if n % 2 == 0 puts n / 2 exit end puts n