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