main :: IO () main = readLn >>= print . f f :: Int -> Int f m = (!! 127) $ iterate (flip mod m . (* 2)) 1