-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU main = readLn >>= print . g where f x p c | m > 0 = (x, c) | otherwise = f d p (c + 1) where (d, m) = divMod x p g x = r2 * (h d2 3 1) where (d2, c2) = f x 2 0 r2 = 1 + (mod c2 2) h 1 _ y = y h z i y | z < i * i = y * z | otherwise = h d (i + 2) (y * r) where (d, c) = f z i 0 r = if 1 == mod c 2 then i else 1