M, D = map(int, input().split()) ans = 23 if M == 8 and D >= 22 or M > 8: ans += 1 print(ans)