import Data.Ratio main = do [a,b,c] <- map read . words <$> getLine :: IO [Int] print $ if 60*a-b <= 0 then -1 else ceiling $ (3600*c) % (60*a-b)