module Main where

import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [x, a, b] <- replicateM 3 readLn :: IO [Int]
    let bn = maximum $ takeWhile (<= x - a) [b, b * 2 ..]
    print $ x - a - bn