A and B are preparing themselves for programming contests.

An important part of preparing for a competition is sharing programming knowledge from the experienced members to those who are just beginning to deal with the contests. Therefore, during the next team training A decided to make teams so that newbies are solving problems together with experienced participants.

A believes that the optimal team of three people should consist of one experienced participant and two newbies. Thus, each experienced participant can share the experience with a large number of people.

However, B believes that the optimal team should have two experienced members plus one newbie. Thus, each newbie can gain more knowledge and experience.

As a result, A and B have decided that all the teams during the training session should belong to one of the two types described above. Furthermore, they agree that the total number of teams should be as much as possible.

There are n experienced members and m newbies on the training session. Can you calculate what maximum number of teams can be formed?


-----Input-----

The first line contains two integers n and m (0 ≤ n, m ≤ 5·10^5) — the number of experienced participants and newbies that are present at the training session. 


-----Output-----

Print the maximum number of teams that can be formed.


-----Examples-----
Input
2 6

Output
2

Input
4 5

Output
3



-----Note-----

Let's represent the experienced players as XP and newbies as NB.

In the first test the teams look as follows: (XP, NB, NB), (XP, NB, NB).

In the second test sample the teams look as follows: (XP, NB, NB), (XP, NB, NB), (XP, XP, NB).

Difficulty: interview

Starter code:

Solutions:
a, b = list(map(int, input().split(' ')))
print(min([a, b, (a+b)//3]))


n, m = list(map(int, input().split()))
s = 0

if n > m:
    t = n
    n = m
    m = t

while n > 0 and m > 1:
    n -= 1
    m -= 2
    s += 1
    if n > m:
        t = n
        n = m
        m = t

print(s)


n,m = list(map(int,input().split()))
n = min(2*m,n)
m = min(2*n,m)
print((n+m)//3)


t = sorted(map(int, input().split()))
t[1] = min(t[1], t[0] * 2)
print(sum(t) // 3)


n, m = list(map(int, input().split()))

ans = 0
while True :
    if n == m == 1 : break
    if n == 0 or m == 0 : break
    if n >= m :
        n -= 2
        m -= 1
    else :
        n -= 1
        m -= 2
    ans += 1
print(ans)


n, m = list(map(int, input().split()))
if n < m:
    n, m = m, n
ans = 0
while n >= 2  and m >= 1:
    ans += 1
    n -= 2
    m -= 1
    if n < m:
        n, m = m, n
print(ans)


import sys
read = lambda t=int: list(map(t,sys.stdin.readline().split()))
array = lambda *ds: [array(*ds[1:]) for _ in range(ds[0])] if ds else 0

n, m = read()

def smart(n, m):
    best = 0
    for a in range(min(n,m)+1):
        b = min((m-a)//2, n-2*a)
        best = max(best, a+b)
    return best

def brute(n, m):
    best = 0
    for a in range(max(n,m)+1):
        for b in range(max(n,m)+1):
            if 2*a+b <= m and 2*b+a <= n:
                best = max(best, a+b)
    return best

# for n in range(10):
#     for m in range(10):
#         if smart(n, m) != brute(n, m):
#             print(smart(n,m), brute(n,m))

print(smart(n, m))
# print(brute(n, m))


n, m = list(map(int, str.split(input())))
teams = 0
while n and m and n + m > 2:

    if n >= m and n > 1:

        teams, n, m = teams + 1, n - 2, m - 1

    elif m > 1:

        teams, n, m = teams + 1, n - 1, m - 2

print(teams)


expert, newbie = map(int, input().strip().split())
minn = min(expert, newbie)
maxx = max(expert, newbie)
counter = 0

while minn - 1 >= 0 and maxx - 2 >= 0:
    minn -= 1
    maxx -= 2
    if minn > maxx:
        minn, maxx = maxx, minn
    counter += 1

print(counter)

n, m = list(map(int,input().split()))
a, c = 0, 0

for a in range(0, min(n, int(m/2)) + 1):
    c = max(c, a + max(0, min( int( (n - a)/2 ) , m - 2 * a) ))

print(c)


# sorry for the source code iam a newbie in Python
n,m = list(map(int,input().split()))
c = min (n,m // 2)
res = 0
for i in range(c + 1):
    n1 = n - i
    m1 = m - i * 2
    res = max (res,i + min (n1 // 2, m1))
print (res)


def main():
    n, m = list(map(int, input().split()))
    if n > m * 2:
        n = m * 2
    elif m > n * 2:
        m = n * 2
    print((n + m) // 3)


def __starting_point():
    main()

__starting_point()

__author__ = 'Krishna'

team_count = 0
jun, sen = (int(i) for i in input().split(" "))
mini = min(jun, sen)
maxi = max(jun, sen)
diff = maxi - mini
if diff < maxi and diff < mini:
    mini -= diff
    maxi -= 2 * diff
    team_count += diff
    team_count += 2 * (mini // 3)
    if mini % 3 == 2:
        team_count += 1
    print(team_count)
else:
    print(mini)

import sys
# sys.stdin = open('in.txt')
R = lambda: list(map(int, input().split()))

n,m = R()
if 2*n<=m:
    print(n)
elif 2*m<=n:
    print(m)
else:
    print((m+n)//3)


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

input_str = input()
n, k = int(input_str.split()[0]), int(input_str.split()[1])
teams = 0
if k>=n*2:
    print (n)
elif n>=k*2:
    print (k)
else:
    while n+k>=3 and k>0 and n>0:
        teams += 1
        if n<k:
            n -= 1
            k -= 2
        else:
            n -= 2
            k -= 1
#        print (n, k)
    print (teams)
            
    


n,m=input().split()
n=int(n)
m=int(m)
k=0
while n+m>2 and n>0 and m>0:
    if m<2*n:
        m-=1
        n-=2
        k+=1
    else:
        n-=1
        m-=2
        k+=1
print(k)    

class C:
    def c(self, n, m):
        total = n+m
        noofteams = int(total/3)
        if noofteams > n:
            noofteams = n
        elif noofteams > m:
            noofteams = m
        return noofteams


def __starting_point():
    values = input().split(' ', 2)
    print(C().c(int(values[0]), int(values[1])))
__starting_point()

import sys

nm=list(map(int,sys.stdin.readline().split()))
n=nm[0]
m=nm[1]
g=0
while n>0 and m>0 and n+m>2:
  if n>m:
    g=g+1
    n=n-2
    m=m-1
  else:
    g=g+1
    m=m-2
    n=n-1

print(g)

n,m=list(map(int,input().split()))
i=0
while n>=2 and m>=2:
    if m>=n:
        m-=2
        n-=1
    elif n>m:
        m-=1
        n-=2
    i+=1
if m==1 and n>=2:
    i+=1
if n==1 and m>=2:
    i+=1
print(i)


n, m = list(map(int, input().split()))

cnt = 0

while min(n, m) >= 1 and max(n, m) >= 2:
    n, m = min(n, m), max(n, m)
    n -= 1
    m -= 2
    cnt += 1

print(cnt)


n, m = list(map(int, input().split(" ")))
total = (n + m) / 3
cnt = 0
while cnt < total and n > 0 and m > 0 :
  cnt+=1
  if n < m :
    n-=1
    m-=2
  else :
    n-=2
    m-=1

if n < 0 or m < 0  : cnt-=1
print(cnt)


a = input("").split(" ")
print(min(int((int(a[1])+int(a[0]))/3), int(a[0]), int(a[1])))


#print(sum(map(int, input().split())) // 3)
import math
n, m = list(map(int, input().split()))
x = (2 * m - n) / 3
y = (2 * n - m) / 3
if x >= 0 and y >= 0:
    print((n + m) // 3)
elif x >= 0 and y <= 0:
    print(n)
else:
    print(m)
    


n, m = map(int, input().split())
n = min(n, 2 * m)
m = min(m, 2 * n)
print((n + m) // 3)