Friends are going to play console. They have two joysticks and only one charger for them. Initially first joystick is charged at a_1 percent and second one is charged at a_2 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.


-----Input-----

The first line of the input contains two positive integers a_1 and a_2 (1 ≤ a_1, a_2 ≤ 100), the initial charge level of first and second joystick respectively.


-----Output-----

Output the only integer, the maximum number of minutes that the game can last. Game continues until some joystick is discharged.


-----Examples-----
Input
3 5

Output
6

Input
4 4

Output
5



-----Note-----

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.

Difficulty: interview

Starter code:

Solutions:
a,b=map(int,input().split())
ans=0
while a>0 and b>0:
    if max(a,b)>1: ans+=1
    if a<b: a+=3
    else: b+=3
    a-=2;b-=2
print(ans)

#! /usr/bin/env python3

def main():
    a, b = map(int, input().split())

    count = 0
    while not ((a <= 1 and b <= 1) or a == 0 or b == 0):
        if a < b:
            a += 1
            b -= 2
        else:
            b += 1
            a -= 2
        count += 1
    print(count)


main()

a1, a2 = list(map(int, input().split()))

c = 0

while (a1 > 1 and a2 > 0) or (a2 > 1 and a1 > 0):
    if a1 >= a2:
        a1 -= 2
        a2 += 1
    else:
        a1 += 1
        a2 -= 2
    c += 1

print(c)


a, b = list(map(int, input().split()))
cnt = 0
while a > 0 and b > 0:
    cnt += 1
    if a < b:
        a += 1
        b -= 2
    else:
        a -= 2
        b += 1
if a < 0 or b < 0:
    cnt -= 1
print(cnt)


a, b = map(int, input().split())
t = 0
while a > 0 and b > 0:
    if a > b or (b == 1 and a != 1) :
        b += 1
        a -= 2
    elif b > a or (a == 1 and b != 1):
        b -= 2
        a += 1
    elif a == b and a != 1:
        b += 1
        a -= 2
    else:
        break
    t += 1
print(t)

#!/usr/bin/env python3

a1, a2 = input().split()
a1, a2 = int(a1), int(a2)

time = 0
while a1 > 0 and a2 > 0:
	if a1 < a2:
		a1 += 1
		a2 -= 2
	else:
		a1 -= 2
		a2 += 1
	if a1 >= 0 and a2 >= 0:
		time += 1

print(time)

a,b = map(int, input().split())
answer = 0
while (a >= 1 and b >= 2) or (b>= 1 and a >= 2):
    if a < b:
        a+=1
        b-=2
        answer+=1
    else:
        b+=1
        a-=2
        answer+=1
print(answer)

a1, a2 = map(int, input().split())
counter = 0
while True:
    if a1 <= 0 or a2 <= 0:
        break
    else:
        if a2 < a1:
            a1, a2 = a2, a1
        if a2 == 1:
            break
        a1 += 1
        a2 -= 2
        counter += 1
print(counter)

a1, a2 = list(map(int, input().split()))
n = 0
while (a1 >= 1 and a2 > 1) or (a1 > 1 and a2 >= 1):
    if a1 < a2:
        a1 += 1
        a2 -= 2
    else:
        a1 -= 2
        a2 += 1
    n += 1
print(n)


a1, a2 = list(map(int, input().strip().split()))
count = 0
while a1 > 0 and a2 > 0:
    if a1 <= a2:
        a1 += 1
        a2 -= 2
    else:
        a2 += 1
        a1 -= 2
    if a1 >= 0 and a2 >= 0:
        count += 1
    if a1 == 0 or a2 == 0:
        break
print(count)


a, b = map(int, input().split())
ans = 0
while a + b > 2 and a > 0 and b > 0:
    ans += 1
    if a < b:
        a += 1
        b -= 2
    else:
        a -= 2
        b += 1
print(ans)

def read_input():
    a1, a2 = list(map(int, input().strip().split()))
    return a1, a2


def solution(a1, a2):
    ans = 0
    while a1 > 0 and a2 > 0:
        if a1 <= 1 and a2 <= 1:
            break
        if a1 <= a2:
            a1 += 1
            a2 -= 2
        else:
            a2 += 1
            a1 -= 2

        ans += 1
    return ans


def __starting_point():
    a1, a2 = read_input()
    print(solution(a1, a2))

__starting_point()

import functools
import math
import sys

a1, a2 = map(int, input().split())
ans = 0
while a1 * a2 != 0:
    if a1 == 1 and a2 == 1:
        break
    if a1 > a2:
        a1 -= 2
        a2 += 1
    else:
        a1 += 1
        a2 -= 2
    #print(a1, a2, ans)
    ans += 1
print(ans)

import math
x,y=(int(z) for z  in input().split())
a=min(x,y)
b=max(x,y)
def g(a,b,res):
    if a*b==0:
        return res
    if a*b==1:
        return res
    k=math.ceil((b-a)/3)
    if k==0:
        k=1
    a+=k
    b-=2*k
    m=min(a,b)
    p=max(a,b)
    return g(m,p,res+k)
print(g(a,b,0))

def find(n1, n2):
    if n1 < 0 or n2 < 0:
        return -1
    if n1 == 0  or n2 == 0:
        return 0
    if res[n1][n2] != -1:
        return res[n1][n2]
    else:
        rel = max(find(n1 + 1, n2 - 2), find(n1 - 2, n2 + 1)) + 1
        res[n1][n2] = rel
        return rel
n1, n2 = map(int, input().split())
res = [[-1] * (301) for i in range(301)]
print(find(n1, n2))

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import itertools

CHARGE = 1
DISCHARGE = -2


def solve(j1, j2):
    if j1 == 1 and j2 == 1:
        return 0
    last_charged = 1 if j1 >= j2 else 2
    for t in itertools.count():
        if j1 <= 0 or j2 <= 0:
            return t
        elif j1 <= 2:
            j1 += CHARGE
            j2 += DISCHARGE
            last_charged = 1
        elif j2 <= 2:
            j1 += DISCHARGE
            j2 += CHARGE
            last_charged = 2
        elif last_charged == 1:
            j1 += CHARGE
            j2 += DISCHARGE
        elif last_charged == 2:
            j1 += DISCHARGE
            j2 += CHARGE


def main():
    j1, j2 = list(map(int, input().split()))
    print(solve(j1, j2))


def __starting_point():
    main()

__starting_point()

a, b = [int(x) for x in input().split()]
count = 0
if a == 1 and b == 1:
    print(0)
else:
    while a > 0 and b > 0:
        if a == 1 or a == 2:
            a += 1
            b -= 2
        elif b == 1 or b == 2:
            b += 1
            a -= 2
        elif a > b:
            a -= 2
            b += 1
        else:
            a += 1
            b -= 2
        count += 1
    print(count)


a, b = list(map(int, input().split()))
count = 0
while True:
    a, b = min(a, b), max(a, b)
    while b > 2:
        a += 1
        b -= 2
        count += 1
    if (b == 2 and a <= 2) or (a == 2 and b <= 2):
        count += 1
        break
    if b == 1 and a == 1:
        break
print(count)


a1, a2 = map(int, input().split())
if (a1 - a2) % 3 == 0:
    if a1 + a2 > 2:
        print(a1 + a2 - 3)
    else:
        print(0)
else:
    print(a1 + a2 - 2)

n, m = [int(x) for x in input().split()]
k = 0
while max(n, m) > 1 and min(m, n) > 0:
    k += 1
    n, m = max(n, m) - 2, min(n, m) + 1
print(k)
    


__author__ = 'sandeepmellacheruvu'
x, y = map(int, input().split())
numMins = 0
prevElse = None
while(True):
    if x > y:
        if prevElse == False:
            if x == 2:
                numMins += 1
            break
        prevElse = False
        while(x - 2 > 0):
            x = x - 2;
            y = y + 1
            numMins += 1
    else:
        if prevElse == True:
            if y == 2:
                numMins += 1
            break
        prevElse = True
        while(y - 2 > 0):
            x = x + 1
            y = y - 2
            numMins += 1
print(numMins)

ch=input()
d=ch.split()
a1=int(d[0])
a2=int(d[1])
somme=0
while a1>0 and a2>0:
    if a1>=a2:
        if a1%2==0:
            S=a1//2-1
            a1=a1-S*2
            a2=a2+S
            somme+=S
           
            
        else:
            S=a1//2
            a1-=S*2
            a2=a2+S
            somme+=S
           
            
    else:
        if a2%2==0:
            S=a2//2-1
            a2-=S*2
            a1=a1+S
            somme+=S
          
           
        else:
            S=a2//2
            a2-=S*2
            a1=a1+S
            somme+=S
          
           
    if (a1==2 and a2==2) or(a1<2 and a2==2) or (a2<2 and a1==2) :
        somme=somme+1
        break
    if a1<2 and a2<2:
        break

print(somme)
        
            
                
                
            


read = lambda: list(map(int, input().split()))
a1, a2 = read()
if a1 <= 1 and a2 <= 1:
    ans = 0
else:
    ans = 0
    cur = 0
    while a1 > 0 and a2 > 0:
        cur = 1 if a1 < a2 else 2
        if cur == 0:
            a1 -= 2
            a2 -= 2
        elif cur == 1:
            a1 += 1
            a2 -= 2
        elif cur == 2:
            a1 -= 2
            a2 += 1
        ans += 1

print(ans)


a, b = map(int, input().split())
cnt = 0
while a > 0 and b > 0 and (b > 1 or a > 1):
    if a < b:
        a += 1
        b -= 2
    else:
        a -= 2
        b += 1
    cnt += 1
print(cnt)

a, b = map(int, input().split(' '))
ans = 0
if a == 1 and b== 1:
	print(0)
	return	
while min(a, b) > 0:
	ans += 1
	if a>b:
		a-=2
		b+=1
	else:
		b-=2
		a+=1
print(ans)