import Data.Char (isSpace) import Data.List (unfoldr) import qualified Data.ByteString.Char8 as BSC8 getIL :: IO [Integer] getIL = unfoldr f <$> BSC8.getLine where f s = do (n, s') <- BSC8.readInteger s return (n, BSC8.dropWhile isSpace s') main :: IO () main = do (n:m:_) <- getIL if n >= m then print 0 else print $ (product [1..n]) `mod` m