a, b = list(map(int, input().split())) print(max((a + b) % 2, a + b - 4 * min(a, b)))