main = do e<-getLine let (a:b:c:[])=map read (words e)::[Integer] d=if (60*a-b)<=0 then -1 else (3600*c) `div` (60*a-b) add=if (60*a-b)<=0 then -1 else (3600*c) `mod` (60*a-b) add2=if add==0 then 0 else 1 print $ if d>=0 && (d+add2)>=1 then d+add2 else -1