import Control.Monad
import Control.Applicative
import Data.List
import qualified Data.Map as Map
import Data.Array
strToInt s = (read :: String -> Int) s

main = do

x <- readLn :: IO Int
a <- readLn :: IO Int
b <- readLn :: IO Int

print $ mod (x-a) b