require 'prime' x = gets.to_i ans = 1 hash = Hash.new(0) Prime.each(Math.sqrt(x)) do |prime| quo, rem = x.divmod(prime) if rem == 0 then hash[prime] += 1 x = quo redo else ans *= prime if hash[prime] % 2 == 1 end end ans *= x puts ans