a, b = map(int, input().split()) x = 2 * a + b y = a + 2 * b print(y // 3 - (x - 1) // 3)