a,b,c=map(int,input().split()) if a*60<=b: print(-1) else: x=0 while a==a: if a*60*x