A,B = map(int,input().split()) S = (A*60+B) % 720 L = 12*B print((S-L)%720*60//11)