-- yukicoder My Practice -- author: Leonardone @ NEETSDKASU main = readLn >>= print . g 6 . f 9 . f 4 where f k x | m > 0 = x | otherwise = f k d where (d, m) = divMod x k g i x | x < k2 = f k1 x | otherwise = g (i + 6) $ f k2 $ f k1 x where k1 = (i - 1) * (i - 1) k2 = (i + 1) * (i + 1)