a, b = map(int,input().split()) sec = (a * 60 + b) * 60 aCalc = sec / 3600 bCalc = (sec % 3600) / 60 positionA = aCalc / 12 * 100 positionB = bCalc / 60 * 100 minimum = 9999 minimumS = -1 for i in range(3900): aCalc = (sec + i) / 3600 bCalc = ((sec + i) % 3600) / 60 positionA = ( aCalc / 12 * 100 ) % 100 positionB = ( bCalc / 60 * 100 ) % 100 difference = abs(positionA - positionB) if minimum > difference: minimum = difference minimumS = i ''' aCalc0 = (sec + minimumS) / 3600 bCalc0 = ((sec + minimumS) % 3600) / 60 positionA0 = ( aCalc0 / 12 * 100 ) % 100 positionB0 = ( bCalc0 / 60 * 100 ) % 100 aCalc1 = (sec + minimumS + 1) / 3600 bCalc1 = ((sec + minimumS + 1) % 3600) / 60 positionA1 = ( aCalc1 / 12 * 100 ) % 100 positionB1 = ( bCalc1 / 60 * 100 ) % 100 if (positionA0 - positionB0)*(positionA1 - positionB1) < 0: minimumS += 1 ''' print(minimumS)