--fib :: Word -> Word fib n = fib' n 1 1 where fib' n x y | n == 1 = 1 | n == 2 = 1 | n == 3 = x | otherwise = fib' (n - 1) (x + y) x main = do x <- getLine print $ mod (fib $ read $ head (words x)) (read (words x !! 1))