m, d = map(int, input().split()) ans = 23 if 8 < m : ans += 1 elif 8 == m : if 22 <= d : ans += 1 print(ans)