{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}

main :: IO ()
main = do
  (x, a, b) <- getInput
  print $ solve x a b

getInput :: IO (Int, Int, Int)
getInput = do
  x <- readLn
  a <- readLn
  b <- readLn
  return (x, a, b)

solve :: Int -> Int -> Int -> Int
solve x a b = (x - a) `mod` b
