open System
// 標準入力からスペース、タブ区切りでトークン列を読み込む
let stdinTokens = seq {
    while true do
        let line =  Console.ReadLine() 
        let tokens = line.Split([|' '; '\t'|], StringSplitOptions.RemoveEmptyEntries)
        yield! tokens
}
let readn n = stdinTokens |> Seq.take n |> List.ofSeq
let readInt n = readn n |> List.map int
let [X; A; B] = readInt 3
printfn "%d" ((X - A)%B)