import Control.Applicative ((<$>)) main :: IO () main = do [s, k] <- fmap read . words <$> getLine :: IO [Int] print $ mod s k