Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at *a*<sub class="lower-index">1</sub> percent and second one is charged at *a*<sub class="lower-index">2</sub> percent. You can connect charger to a joystick only at the beginning of each minute. In one minute joystick either discharges by 2 percent (if not connected to a charger) or charges by 1 percent (if connected to a charger).

Game continues while both joysticks have a positive charge. Hence, if at the beginning of minute some joystick is charged by 1 percent, it has to be connected to a charger, otherwise the game stops. If some joystick completely discharges (its charge turns to 0), the game also stops.

Determine the maximum number of minutes that game can last. It is prohibited to pause the game, i. e. at each moment both joysticks should be enabled. It is allowed for joystick to be charged by more than 100 percent.
The first line of the input contains two positive integers *a*<sub class="lower-index">1</sub> and *a*<sub class="lower-index">2</sub> (1 ≤ *a*<sub class="lower-index">1</sub>, *a*<sub class="lower-index">2</sub> ≤ 100), the initial charge level of first and second joystick respectively.
In the first sample game lasts for 6 minute by using the following algorithm:
 -  at the beginning of the first minute connect first joystick to the charger, by the end of this minute first joystick is at 4%, second is at 3%; -  continue the game without changing charger, by the end of the second minute the first joystick is at 5%, second is at 1%; -  at the beginning of the third minute connect second joystick to the charger, after this minute the first joystick is at 3%, the second one is at 2%; -  continue the game without changing charger, by the end of the fourth minute first joystick is at 1%, second one is at 3%; -  at the beginning of the fifth minute connect first joystick to the charger, after this minute the first joystick is at 2%, the second one is at 1%; -  at the beginning of the sixth minute connect second joystick to the charger, after this minute the first joystick is at 0%, the second one is at 2%. 
After that the first joystick is completely discharged and the game is stopped.
3 5
6
4 4
5
100 100
197
1 100
98
100 1
98
1 4
2
1 1
0
8 8
13
7 2
7
24 15
36
19 30
47
15 31
44
14 15
27
58 33
89
15 25
38
59 45
102
3 73
74
48 1
47
100 25
122
40 49
86
85 73
155
29 1
28
74 25
97
24 57
78
23 12
33
2 99
99
98 2
97
2 97
97
30 54
81
32 53
82
32 54
84
1 2
1
2 1
1
2 2
1
1 3
2
3 1
2
1 4
2
2 3
3
3 2
3
import fileinput

def calc(a,b, memo):
    if a <= 0 or b <= 0:
        return 0
    return max(1 + memo[(a-2,b + 1)], 1+ memo[(a + 1, b -2)])



memo = {}
for line in fileinput.input():
    a, b = line.split()
    a = int(a)
    b = int(b)
    originalab = a, b
    
    # This should be a good enough upper bound
    a = 2*a
    b = 2*b
    for i in range(max(a+1, b+1)):
        memo[(i, 0)] = 0
        memo[(i, -1)] = 0
        memo[(0,i)] = 0
        memo[(-1,i)] = 0


    for diagonal_i in range(max(a+1,b+1)):
        # diagonal ending in (0,b+1)
        #print()
        #print("Diagonal ", diagonal_i)
        # Check if the original number has been found
        #print("Original ab in memo ", originalab in memo)

        for i in range(0, diagonal_i):
            currxy = (i, diagonal_i -i)
            #print("Currxy ", currxy)
            min_i = calc(*currxy, memo)
            memo[currxy] = min_i

        if originalab in memo:
            print(memo[originalab])
            break
            

#we can do a dynamic programming algorithm in pseudo polynomial
# weird thing is that a component in dp has b+1 so we cannot initialize
# only one value for the memoization, but the dp graph is more complicated
# We will have to initialize values  (a,0) and (b , 0) to zero

# If playerb has 0 battery in the next minute then the game stops
# We have to find a smart way to fill the memoization table
# We have to do going by filling the rows  in A wont work

# Actually want to try doing recursive calls and having memoization not sure if it would work though because you can get in an infinite loop

# Can dp even work, is the call graph acyclic?
# Yes it is for every (a,b) the underlying calls are above the diagonal of (a,b)
# iterate ofver diagonals
# we want t he max xolution so we cant do approximate stuff

# Problem with the diagonals are final a,b needs more


