H, M = map(int,input().split()) print(int((H * 3600 / 11 - M * 60) % 3927.272727))