import Control.Monad

solver :: [Int] -> Int
solver [x, a, b] = c
    where y = x - a
          c = y - b * (y `div` b)

main :: IO()
main = do
    line <- map (read :: String -> Int) <$> replicateM 3 getLine
    print $ solver line
