def main(): X, Y = map(int, input().split()) if abs(X - Y) == 8: print((X + Y) // 2) else: print((6 + (X + Y) // 2) % 12) if __name__ == "__main__": main()