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).

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Number theory

Implementation

Greedy algorithms


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


(n, m) = map(int, input().split())
maxi = max(n, m)
mini = n + m - maxi
count = 0
while not (mini == 0 or mini == maxi == 1):
	maxi -= 2
	mini -= 1
	if maxi < mini:
		(maxi, mini) = (mini, maxi)
	count += 1
print(count)


(n, m) = map(int, input().split())
if n == 0 or m == 0:
	print(0)
else:
	print(min(n, m, (n + m) // 3))


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


(xp, nb) = map(int, input().split())
print(min(xp, nb, (xp + nb) // 3))


(a, b) = map(int, input().split())
c = min(a, b)
d = max(a, b)
k = int(0)
while c != d and c > 0 and (d > 0):
	c = c - 1
	d = d - 2
	k = k + 1
k = k + c // 3 * 2
c = c % 3
d = d % 3
if c == 1 and d == 2:
	k = k + 1
elif c == 2 and d == 1:
	k = k + 1
elif c == 2 and d == 2:
	k = k + 1
print(k)


(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)


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()


(n, m) = [int(x) for x in input().split()]
print(min(n, m, (m + n) // 3))


(m, n) = map(int, input().split())
c = 0
while n + m >= 3 and n > 0 and (m > 0):
	if n >= m:
		n -= 2
		m -= 1
		c += 1
	else:
		m -= 2
		n -= 1
		c += 1
print(c)


import itertools as ittls
from collections import Counter
import string

def sqr(x):
	return x * x

def inputarray(func=int):
	return map(func, input().split())
(n, m) = sorted(inputarray())
m = min(2 * n, m)
print((n + m) // 3)


a = [int(i) for i in input().split(' ')]
new = a[0]
old = a[1]
k = 0
while new >= 0 and old >= 0:
	if old > new:
		k = k + 1
		old = old - 2
		new = new - 1
	else:
		k = k + 1
		old = old - 1
		new = new - 2
print(k - 1)


(a, b) = [int(x) for x in input().split()]
if a == 0 or b == 0 or (a == 1 and b == 1):
	print(0)
elif a * 2 <= b or b * 2 <= a:
	print(min(a, b))
else:
	print((a + b) // 3)


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


import sys
import collections
from collections import Counter
import itertools
import math
import timeit

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
(a, b) = mi()
print(min(abs(b - a), a, b) + 2 * (min(a, b) - min(abs(b - a), a, b)) // 3)


__author__ = 'artyom'

def main():
	(a, b) = read(3)
	return min(a, b, (a + b) // 3)

def read(mode=2):
	inputs = input().strip()
	if mode == 0:
		return inputs
	if mode == 1:
		return inputs.split()
	if mode == 2:
		return int(inputs)
	if mode == 3:
		return list(map(int, inputs.split()))

def write(s='\n'):
	if s is None:
		s = ''
	if isinstance(s, list):
		s = ' '.join(map(str, s))
	s = str(s)
	print(s, end='')
write(main())


(n, m) = map(int, input().split())
ans = 0
for i in range(n + 1):
	ta = min(i, m // 2)
	(nn, mm) = (n - ta, m - ta - ta)
	tb = min(nn // 2, mm)
	ans = max(ans, ta + tb)
print(ans)


def minimum(a, b, c):
	if a < b and a < c:
		return a
	elif b < a and b < c:
		return b
	else:
		return c
(n, m) = [int(x) for x in input().split()]
result = minimum(n, m, (m + n) // 3)
print(result)


(a, b) = map(int, input().split())
(a, b) = (min(a, b), max(a, b))
a_alt = a
count = 0
while a != b and a != 0 and (b != 0):
	a -= 1
	b -= 2
	count += 1
temp = a_alt - count
if temp % 3 == 2:
	count += 1
print(2 * (temp // 3) + count)


(n, m) = map(int, input().split())
if m > n:
	(n, m) = (m, n)
k = n - m
if n - 2 * k >= 0 and m - k > 0:
	l = k
	n -= 2 * k
	m -= k
	k = min(n, m) // 3
	l += k * 2
	n -= k * 3
	m -= k * 3
	if n > 1 and m > 1:
		l += 1
else:
	l = min(n // 2, m)
print(l)


(n, m) = map(int, input().split())
if m < n * 2 and n < m * 2:
	print((m + n) // 3)
else:
	print(min(n, m))


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


l = list(map(int, input().split()))
(n, m) = (l[0], l[1])
c = 0
while n >= 1 and m >= 1:
	f = 0
	if n <= m and n >= 1 and (m >= 2):
		n -= 1
		m -= 2
		c += 1
		f = 1
	elif m < n and m >= 1 and (n >= 2):
		m -= 1
		n -= 2
		c += 1
		f = 1
	if f == 0:
		break
print(c)


(n, m) = input().split()
n = int(n)
m = int(m)
ans = 0
while (n + m >= 3) & (n >= 1) & (m >= 1):
	if n > m:
		n -= 2
		m -= 1
		ans += 1
	else:
		n -= 1
		m -= 2
		ans += 1
print(ans)


def cal(x, n, m):
	if m >= 2 * x:
		m -= 2 * x
		n -= x
		v = x
	else:
		v = 0
	v += min(m, n // 2)
	return v
(n, m) = map(int, input().split())
(n, m) = (min([n, m]), max([n, m]))
c = 0
for i in range(1, n + 1):
	c = max(c, cal(i, n, m))
print(c)


(n, m) = [int(i) for i in input().split()]
print(min(n, m, (n + m) // 3))


(n, m) = [int(i) for i in input().split()]
k = 0
while n >= 2 and m >= 1 or (n >= 1 and m >= 2):
	if m > n:
		(m, n, k) = (m - 2, n - 1, k + 1)
	else:
		(m, n, k) = (m - 1, n - 2, k + 1)
print(k)


(n, m) = map(int, input().split())
if max(n, m) < 2:
	print(0)
	quit()
if min(n, m) * 2 <= max(n, m):
	print(min(n, m))
	quit()
big = max(m, n)
small = min(m, n)
diff = big - small
print((small - diff) // 3 * 2 + diff + (1 if (small - diff) % 3 == 2 else 0))


buff = list(map(int, input().split()))
n = buff[0]
m = buff[1]
max = 0
for i in range(min(m // 2 + 1, n + 1)):
	if min(m - i * 2, (n - i) // 2) + i > max:
		max = min(m - i * 2, (n - i) // 2) + i
print(max)


(x, y) = map(int, input().split())
l = 0
if y < x:
	(x, y) = (y, x)
while x > 0 and y > 1:
	x -= 1
	y -= 2
	l += 1
	if y < x:
		(x, y) = (y, x)
print(l)


(n, m) = 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) = map(int, input().split())
maxi = 0
if n > m:
	temp = n
	n = m
	m = temp
temp = min(n, m - n)
maxi = temp
n -= temp
m -= temp
temp = min(n, m)
maxi += int(2 * temp / 3)
print(maxi)


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)


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
mp = lambda : list(map(int, cin().split()))
(n, m) = mp()
count = 0
while True:
	if n and m >= n and (m > 1):
		count += 1
		n -= 1
		m -= 2
	elif m and n >= m and (n > 1):
		count += 1
		n -= 2
		m -= 1
	else:
		cout(str(count) + '\n')
		break


liste = input().split(' ')
x = int(liste[0])
n = int(liste[1])
if n // 2 > x:
	print(x)
elif n == 1 and x == 1:
	print('0')
else:
	i = 0
	while x > 0 and n > 0:
		if 2 * n > x:
			x -= 1
			n -= 2
			i += 1
		else:
			x -= 2
			n -= 1
			i += 1
	if n < 0 or x < 0:
		i -= 1
	print(i)


[n, k] = list(map(int, input().split(' ')))
m = min(n, k)
print(min(m, (n + k) // 3))


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


__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)


from sys import stdin
input = stdin.readline

def training(m, n, t=0):
	if m > n:
		(m, n) = (n, m)
	if not (m and n):
		return 0
	if m == 1:
		return int(n > 1)
	if m * 2 <= n:
		return m
	for i in range(m // 2 + 1):
		if not m:
			return t
		elif m == 1:
			return t + int(n > 1)
		elif m * 2 <= n:
			return m + t
		else:
			m -= 2
			n -= 1
			t += 1
print(training(*map(int, input().split())))


(a, b) = map(int, input().split(' '))
print(min(min(a, b), (a + b) // 3))


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


(n, m) = map(int, input().split())
m_t = 0
for i in range(0, min(n, m // 2) + 1):
	t_2 = min((n - i) // 2, m - i * 2)
	m_t = max(m_t, t_2 + i)
print(m_t)


def solve(exp, new):
	ans = 0
	while exp > 0 and new > 0:
		biggest = max(exp, new)
		if biggest == 1:
			break
		half = biggest // 2
		if half % 2 != 0:
			half += 1
		minusSmall = half // 2
		if exp > new:
			exp -= half
			if minusSmall > new:
				ans += new
				new = 0
			else:
				new -= minusSmall
				ans += minusSmall
		else:
			new -= half
			if minusSmall > exp:
				ans += exp
				exp = 0
			else:
				exp -= minusSmall
				ans += minusSmall
	return ans
(e, n) = list(map(int, input().split()))
print(solve(e, n))


(x, y) = map(int, input().split())
print(min(x, y, (x + y) // 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)


(i_pro, i_noob) = map(int, input().split())
i_druz = 0
while i_pro + i_noob >= 3 and i_pro and i_noob:
	if i_pro > i_noob:
		i_pro -= 2
		i_noob -= 1
	else:
		i_pro -= 1
		i_noob -= 2
	i_druz += 1
print(i_druz)


import math
(n, m) = map(int, input().split())
if n < m:
	(n, m) = (m, n)
if n >= m * 2:
	print(m)
	exit()
x = (2 * m - n) / 3
y = (2 * n - m) / 3
ans = math.floor(x) + math.floor(y)
if 2 * math.ceil(x) + math.floor(y) <= m and math.ceil(x) + 2 * math.floor(y) <= n:
	ans = max(ans, math.ceil(x) + math.floor(y))
if 2 * math.floor(x) + math.ceil(y) <= m and math.floor(x) + 2 * math.ceil(y) <= n:
	ans = max(ans, math.floor(x) + math.ceil(y))
print(ans)


[n, m] = list(map(float, input().split()))
t = 0
while max(m, n) >= 2 and min(m, n) >= 1:
	if m > n:
		m -= 2
		n -= 1
	else:
		n -= 2
		m -= 1
	t += 1
print(t)


(n, m) = list(map(int, input().split()))
total = 0
while n >= 1 and m >= 2 or (m >= 1 and n >= 2):
	(n, m) = sorted((n, m))
	m -= 2
	n -= 1
	total += 1
print(total)


(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)


(a, b) = map(int, input().split())
(a, b) = (min(a, b), max(a, b))
if b - a >= a:
	print(a)
else:
	res = b - a
	a -= res
	res += a // 3 * 2
	if a % 3 == 2:
		res += 1
	print(res)


(n, m) = list(map(int, input().split()))
maxt = 0
for i in range(m + 1):
	type1 = min(n // 2, i)
	nn = n - type1 * 2
	mm = m - type1
	type2 = min(nn, mm // 2)
	total = type1 + type2
	maxt = max(total, maxt)
print(maxt)


import sys
(n, m) = map(int, sys.stdin.readline().split())
ans = 0
for i in range(n + 1):
	leftm = m - 2 * i
	if leftm < 0:
		break
	cur = i
	leftn = n - i
	ans = max(ans, i + min(leftm, int(leftn / 2)))
print(ans)


def get_range(num):
	return range(int(num - 10), int(num + 10))

def is_valid(x, y, n, m):
	return 2 * x + y <= n and x + 2 * y <= m and (x >= 0) and (y >= 0)

def main():
	(n, m) = [int(t) for t in input().split()]
	if 2 * n <= m:
		print(n)
		return
	if 2 * m <= n:
		print(m)
		return
	x = (2 * n - m) / 3
	y = (2 * m - n) / 3
	max_xy = 0
	for xi in get_range(x):
		for yi in get_range(y):
			if is_valid(xi, yi, n, m):
				max_xy = max(max_xy, xi + yi)
	print(max_xy)
main()


import sys
import math
from pprint import pprint
inp = input()
(n, m) = [int(i) for i in inp.strip().split()]
if n < m:
	(n, m) = (m, n)
c = n - m
if c > m:
	print(m)
else:
	print(c + (m - c) * 2 // 3)


a = list(map(int, input().split()))
if a[0] >= 2 * a[1]:
	print(a[1])
elif a[1] >= 2 * a[0]:
	print(a[0])
else:
	print((a[0] + a[1]) // 3)


(a, b) = map(int, input().split())
maxi = 0
for x in range(a + 1):
	if 2 * x > b:
		break
	p = a - x
	q = b - 2 * x
	y = min(p // 2, q)
	maxi = max(maxi, x + y)
print(maxi)


mas = [int(i) for i in input().split()]
(n, m) = (mas[0], mas[1])
c = 0
while not (n <= 0 or m <= 0) and (not n | m == 1):
	if n >= m:
		n -= 2
		m -= 1
	else:
		n -= 1
		m -= 2
	c += 1
print(c)


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


(n, m) = map(int, input().split())
ans = 0
for i in range(n + 1):
	cur = i
	leftn = n - i
	leftm = m - 2 * i
	if leftm >= 0:
		cur += min(leftm, leftn // 2)
		ans = max(ans, cur)
print(ans)


def main():
	(n, m) = map(int, input().split())
	if m >= 2 * n:
		print(n)
		return
	elif n >= 2 * m:
		print(m)
		return
	teams = 0
	while True:
		if n <= m:
			n -= 1
			m -= 2
		else:
			m -= 1
			n -= 2
		if n > 0 and m > 0:
			teams += 1
		elif n == 0 and m >= 0:
			teams += 1
			break
		elif m == 0 and n >= 0:
			teams += 1
			break
		else:
			break
	print(teams)
main()


import sys

class Training:

	def __init__(self, exp, new):
		self.exp = exp
		self.new = new

	def calTeam(self):
		team = 0
		ex = self.exp
		eb = self.new
		while ex > 0 and eb > 0:
			if ex == 1 and eb == 1:
				break
			elif ex > eb:
				ex -= 2
				eb -= 1
			else:
				eb -= 2
				ex -= 1
			team += 1
		return team

	def calType(self, exp, new):
		team = 0
		minTeam = min(exp // 2, new)
		new -= minTeam
		exp -= 2 * minTeam
		team += minTeam
		minAnother = min(new // 2, exp)
		team += minAnother
		return team

def main():
	(ex, nb) = [int(x) for x in sys.stdin.readline().split()]
	ab = Training(ex, nb)
	print(ab.calTeam())
main()


import os
import sys
from io import BytesIO, IOBase
import math

def main():
	(n, m) = map(int, input().split(' '))
	print(min(n, m, (n + m) // 3))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


(XP, NB) = [int(x) for x in input().split()]
if NB >= 2 * XP:
	team = XP
elif XP >= 2 * NB:
	team = NB
else:
	team = (XP + NB) // 3
print(team)


import sys
(n, m) = map(int, sys.stdin.readline().split())
if n < m:
	(m, n) = (n, m)
if 2 * m <= n:
	print(m)
else:
	print((n + m) // 3)


(n, m) = [int(x) for x in input().split()]
if m >= 2 * n:
	print(n)
elif 2 * m <= n:
	print(m)
else:
	print((m + n) // 3)


s = list(map(int, input().split()))
(a, b) = (max(s), min(s))
cnt = 0
while a > b:
	if b == 0:
		print(cnt)
		exit()
	a -= 2
	b -= 1
	cnt += 1
print((a % 3 == 2) + cnt + 2 * (a // 3))


def match(x, y):
	total = 0
	small = min(x, y)
	large = max(x, y)
	while small > 0 and large > 1:
		total += 1
		s = small - 1
		m = large - 2
		small = min(s, m)
		large = max(s, m)
	return total
while True:
	try:
		text = input()
		if text == '':
			break
		else:
			(ex, nb) = text.split(' ')
			print(match(int(ex), int(nb)))
	except:
		break


n = input()
(a, b) = (int(x) for x in n.split())
print(int(min(min(a, b), (a + b) / 3)))


(e, n) = map(int, input().split())
print(min((e + n) // 3, e, n))


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


(n, m) = map(int, input().split())
c = 0
while n > 0 and m > 0:
	if n == 1 and m == 1:
		break
	elif n < m or n == m:
		n = n - 1
		m = m - 2
	elif n > m:
		n = n - 2
		m = m - 1
	c = c + 1
print(c)


def solve(argv):
	x = argv[0]
	y = argv[1]
	if x < y:
		return solve((y, x))
	if x >= 2 * y:
		return y
	return (x + y) // 3
print(solve(tuple(map(int, input().split(' ')))))


import sys
import math
import bisect

def solve(n, m):
	max_val = 0
	for i in range(n // 2 + 1):
		if i <= m:
			x = n - i * 2
			y = m - i
			val = i
			val += min(x, y // 2)
			max_val = max(max_val, val)
		else:
			break
	return max_val

def main():
	(n, m) = map(int, input().split())
	ans = solve(n, m)
	print(ans)
main()


(n, m) = [int(i) for i in input().split()]
sum = 0
while n > 0 and m > 0:
	if n > m and n > 1:
		n -= 2
		m -= 1
		sum += 1
	elif n < m and m > 1:
		n -= 1
		m -= 2
		sum += 1
	elif n == m and n > 1 and (m > 1):
		n -= 1
		m -= 2
		sum += 1
	else:
		break
print(sum)


(a, b) = map(int, input().split())
c = max(a, b)
d = min(a, b)
if c >= 2 * d:
	print(d)
else:
	print(int((c + d) / 3))


x = [int(i) for i in list(input().split())]
xp = x[0]
nb = x[1]
j = 0
while nb > 0 and xp > 0:
	if xp > 0 and nb >= 2 * xp:
		j += xp
		xp = 0
	elif nb > 0 and xp > 1:
		j += 1
		xp -= 2
		nb -= 1
	else:
		nb = 0
print(j)


import sys
from collections import *
import math
input = sys.stdin.readline
(n, m) = [int(x) for x in input().split()]
res = 0
while m >= 1 and n >= 2 or (n >= 1 and m >= 2):
	if n > m:
		(m, n) = (n, m)
	m -= 2
	n -= 1
	res += 1
print(res)


(ans1, ans2) = map(int, input().split())
print(int(min(ans1, ans2, (ans1 + ans2) / 3)))


t = 0
(n, m) = map(int, input().split())
if n == m:
	print(2 * n // 3)
else:
	for x in range(n + 1):
		if m - 2 * x >= 0:
			t = max(t, x + min(m - 2 * x, (n - x) // 2))
	print(t)


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect, insort
from time import perf_counter
from fractions import Fraction
import copy
from copy import deepcopy
import time
starttime = time.time()
mod = int(pow(10, 9) + 7)
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def L():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass

def pmat(A):
	for ele in A:
		print(*ele, end='\n')
(n, m) = L()
if n == 0 or m == 0:
	print(0)
	exit()
ans = 0
for i in range(0, n + 1 - n % 2, 2):
	rem_m = max(0, m - i // 2)
	y = max(0, min(n - i, rem_m // 2))
	ans = max(ans, y + min(i // 2, m))
print(ans)
endtime = time.time()


(n, m) = map(int, input().split())
Max = max(n, m)
Min = min(n, m)
result = 0
while Max != 0 and Min != 0 and (Max + Min > 2):
	Max -= 2
	Min -= 1
	Max2 = Max
	Min2 = Min
	Max = max(Max2, Min2)
	Min = min(Max2, Min2)
	result += 1
print(result)


l = list(map(int, input('').split()))
n = l[0]
m = l[1]
if n < 2 and m < 2:
	print(0)
elif n >= m:
	d = n // 2
	if m < d:
		print(m)
	else:
		print((n + m) // 3)
else:
	d = m // 2
	if n < d:
		print(n)
	else:
		print((m + n) // 3)


(pro, noob) = map(int, input().split())
maxTeam = (pro + noob) // 3
minPeople = maxTeam
if pro < minPeople:
	print(pro)
elif noob < minPeople:
	print(noob)
else:
	print(maxTeam)


lst = list(map(int, input().rstrip().split()))
n = lst[0]
m = lst[1]
if n <= m / 2:
	print(n)
elif m <= n / 2:
	print(m)
else:
	print(int((n + m) / 3))


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
(n, m) = sorted(INL())
if 2 * n <= m:
	OPS(n)
else:
	x = 2 * n - m
	if x % 3 == 2:
		OPS(m - n + x // 3 * 2 + 1)
	else:
		OPS(m - n + x // 3 * 2)


import math
(a, b) = input().split()
a1 = int(a)
b1 = int(b)
if a1 <= 1 and b1 <= 1:
	print(0)
elif a1 > 1 and b1 == 1:
	print(1)
elif a1 == 1 and b1 > 1:
	print(1)
elif a1 == 0 or b1 == 0:
	print(0)
else:
	ng = 0
	while True:
		if a1 > b1:
			if a1 >= 2:
				b1 -= 1
				a1 -= 2
				ng += 1
			else:
				break
		elif b1 >= 2:
			a1 -= 1
			b1 -= 2
			ng += 1
		else:
			break
		if a1 == 0:
			break
		if b1 == 0:
			break
	print(ng)


(n, m) = map(int, input().split())
i = 0
while 1:
	if n >= m:
		n = n - 2
		m = m - 1
	else:
		n = n - 1
		m = m - 2
	if n < 0 or m < 0:
		break
	else:
		i = i + 1
print(i)


(n, m) = map(int, input().split())
s = 0
for i in range(0, n // 2 + 1):
	if m >= i:
		t = min(n - 2 * i, (m - i) // 2)
		s = max(s, t + i)
print(s)


import os
list = input().split(' ')
m = int(list[1])
n = int(list[0])
result = 0
while n + m >= 3 and n > 0 and (m > 0):
	if n > m:
		n -= 2
		m -= 1
		result += 1
	else:
		n -= 1
		m -= 2
		result += 1
print(result)


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) = list(map(int, input().split()))
n = min(2 * m, n)
m = min(2 * n, m)
print((n + m) // 3)


import sys
(n, m) = map(int, input().split())
ans = 0
for a in range(min(n + 1, m // 2 + 1)):
	ans = max(ans, a + min((n - a) // 2, m - 2 * a))
print(ans)


s = input().split()
n = int(s[0])
m = int(s[1])
x = [n, m]
x.sort()
if n + m > 2 and n > 0 and (m > 0):
	if x[1] // x[0] >= 2:
		print(x[0])
	else:
		print((n + m) // 3)
else:
	print(0)


(n, m) = list(map(int, input().split()))
ans = 0
for k1 in range(0, min(n, m // 2) + 1):
	k2 = min((n - k1) // 2, m - 2 * k1)
	ans = max(ans, k1 + k2)
print(ans)


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


import atexit
import io
import sys
from collections import deque
sys.setrecursionlimit(123456)
_I_B = sys.stdin.read().splitlines()
input = iter(_I_B).__next__
_O_B = io.StringIO()
sys.stdout = _O_B

@atexit.register
def write():
	sys.__stdout__.write(_O_B.getvalue())

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


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


import sys
(n, m) = input().split(' ')
n = int(n)
m = int(m)
if m == 0 or n == 0:
	print(0)
	sys.exit()
if m > n:
	while n * 2 > m:
		n -= 1
		m += 1
	print(n)
else:
	while m * 2 > n:
		n += 1
		m -= 1
	print(m)


from sys import *
inp = lambda : stdin.readline()

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


from math import ceil, log, floor, sqrt
import math
k = 1

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def find_mx_teams(n, m):
	cnt = 0
	f = min(n, max((2 * m - n) // 3, 0))
	s = min(m, max((2 * n - m) // 3, 0))
	n -= f + 2 * s
	m -= 2 * f + s
	cnt += f + s
	if n > 0 and m > 1:
		cnt += 1
		n -= 1
		m -= 2
	if m > 0 and n > 1:
		cnt += 1
		n += 1
		m += 2
	return cnt
t = 1
while t:
	t = t - 1
	(k, g) = (0, 0)
	points = []
	(n, m) = map(int, input().split())
	print(find_mx_teams(n, m))


(numberOfExperiencedParticipants, numberOfNewbies) = map(int, input().split())
print(min(numberOfExperiencedParticipants, numberOfNewbies, (numberOfExperiencedParticipants + numberOfNewbies) // 3))


(n, m) = (int(i) for i in input().split())
k1 = max(n, m)
k2 = min(n, m)
if k1 <= 1:
	print(0)
elif k1 >= 2 * k2:
	print(k2)
else:
	print((n + m) // 3)


import sys
input = sys.stdin.buffer.readline
(n, m) = map(int, input().split())
if 2 * min(n, m) <= max(n, m):
	print(min(n, m))
else:
	print(int((n + m) / 3))


def comand(n, m):
	return min(m, min(n, (m + n) // 3))
(N, M) = [int(i) for i in input().split()]
print(comand(N, M))


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


mod = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
(n, m) = f()
if n > m:
	(n, m) = (m, n)
(i, j) = (0, 0)
c = 0
while 1:
	n -= 1
	m -= 2
	if n > m:
		(n, m) = (m, n)
	if n >= 0 and m >= 0:
		c += 1
	else:
		break
print(c)


(m, n) = map(int, input().split())
maximum = max(m, n)
minimum = min(m, n)
ans = 0
if maximum <= 2 * minimum:
	ans = maximum - minimum + 2 * (minimum - (maximum - minimum)) // 3
else:
	ans = minimum
print(ans)


l = input()
l = l.split(' ')
n = int(l[0])
m = int(l[1])
ans = 0
if m > n:
	x = m
	m = n
	n = x
while n > m:
	if m == 0:
		break
	n -= 2
	m -= 1
	ans += 1
if m == n:
	ans += (m + n) // 3
print(ans)


def inp():
	return map(int, input().split())
(n, m) = inp()
from math import *
mi = min(n, m)
print(min((n + m) // 3, mi))


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


(n, m) = [int(x) for x in input().split()]
ans = 0
while n > 0 and m > 0:
	if n == 1 and m == 1:
		break
	if n < m:
		n -= 1
		m -= 2
	else:
		m -= 1
		n -= 2
	ans += 1
print(ans)


(n, m) = [int(x) for x in input().split()]
groupTwo = min(n, m)
teams = 0
left = max(n, m) - groupTwo
if left >= groupTwo:
	teams = groupTwo
	groupTwo = 0
else:
	teams = left
	groupTwo -= teams
while groupTwo - 3 >= 0:
	groupTwo -= 3
	teams += 2
if groupTwo == 2:
	teams += 1
print(teams)


from math import *
from collections import *
from random import *
from bisect import *
import sys
input = sys.stdin.readline

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())

def inp():
	return int(input())
(a, b) = ma()
print(min(a, b, (a + b) // 3))


s = input().split()
exp = int(s[0])
nub = int(s[1])
grupo = 0
while exp != 0 and nub != 0:
	if not (exp == 1 and nub == 1):
		if exp > nub:
			exp -= 2
			nub -= 1
			grupo += 1
		else:
			exp -= 1
			nub -= 2
			grupo += 1
	else:
		exp -= 1
print(grupo)


from sys import stdin
(M, N) = map(int, stdin.readline().split())
print(max((i + min(N - 2 * i, (M - i) // 2) for i in range(M + 1))))


(n, m) = map(int, input().split())
ans = 0
for i in range(0, 10 ** 6):
	if i <= n and 2 * i <= m:
		cans = i
		n1 = n - i
		m1 = m - 2 * i
		cans += min(n1 // 2, m1)
		ans = max(ans, cans)
print(ans)


def count_groups(more, less):
	groups = 0
	while more - 2 >= 0 and less - 1 >= 0:
		groups += 1
		more -= 2
		less -= 1
		if more < less:
			more ^= less
			less ^= more
			more ^= less
	return groups

def main():
	(experienced_count, newbies_count) = map(int, input().split())
	groups = count_groups(max(experienced_count, newbies_count), min(experienced_count, newbies_count))
	print(groups)
main()


(n1, n2) = map(int, input().split())
print(min(n1, min(n2, (n1 + n2) // 3)))


import math

def get_primes(prime_supr):
	is_prime = [0] * 2 + [1] * prime_supr
	for i in range(2, int(math.sqrt(prime_supr)) + 1):
		if is_prime[i]:
			for j in range(i * i, prime_supr + 1, i):
				is_prime[j] = 0
	return is_prime
get_int = lambda : map(int, input().split())
(n, m) = get_int()
ans = 0
while n >= 1 and m >= 1 and (n + m >= 3):
	ans += 1
	if n > m:
		n -= 2
		m -= 1
	else:
		n -= 1
		m -= 2
print(ans)


(XP, NB) = map(int, input().split())
print(min([XP, NB, (XP + NB) // 3]))


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


(n, m) = sorted(map(int, input().split()))
a = n // 3000000
(n, m) = (n - a * 3, m - a * 3)
while n * m > 1:
	a += 1
	(n, m) = sorted([n - 1, m - 2])
print(a)


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(teams)


def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def li():
	return list(mi())
import string
(n, m) = mi()
a = (m + n) // 3
print(min(n, m, a))


(p, q) = map(int, input().split())
s = 0
while p > 0 and q > 0:
	if p > q:
		p -= 2
		q -= 1
	else:
		p -= 1
		q -= 2
	s += 1
if p < 0 or q < 0:
	s -= 1
print(s)


(n, m) = map(int, input().split())
ans = 0
while True:
	(n, m) = (max(n, m), min(n, m))
	if n >= 2 and m >= 1:
		n -= 2
		m -= 1
		ans += 1
	else:
		break
print(ans)


import sys
input = sys.stdin.readline

def solve(n, m):
	ans = 0
	while n and m:
		if n == m == 1:
			break
		if n >= m + 1:
			n -= 2
			m -= 1
		else:
			n -= 1
			m -= 2
		ans += 1
	print(ans)
(n, m) = map(int, input().split(' '))
solve(n, m)


(a, b) = sorted(map(int, input().split()))
print(0 if a == 0 else a if a * 2 <= b else (a + b) // 3)


import sys, os
from collections import Counter
import heapq
import math
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def listt():
	return [int(i) for i in input().split()]
t = 1
for _ in range(t):
	(n, m) = map(int, input().split())
	k = min(n // 2, m)
	ans = 0
	for i in range(k + 1):
		ans = max(ans, i + min(n - 2 * i, (m - i) // 2))
	print(ans)


x = [int(z) for z in input().split()]
teams = 0
exp = x[0]
begi = x[1]
while exp > 0 and begi > 0 and (exp > 1 or begi > 1):
	while exp >= begi and exp > 1 and (begi > 0):
		teams += 1
		exp -= 2
		begi -= 1
	while begi > exp and begi > 1 and (exp > 0):
		teams += 1
		begi -= 2
		exp -= 1
print(teams)


(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)


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


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


(n, e) = map(int, input().split())
groups = 0
small = min(n, e)
big = max(n, e)
for i in range(big):
	if big >= 2 and small >= 1:
		groups += 1
		big -= 2
		small -= 1
	elif big >= 1 and small >= 2:
		groups += 1
		big -= 1
		small -= 2
	else:
		break
	a = small
	b = big
	small = min(a, b)
	big = max(a, b)
print(groups)


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


input = input().split(' ')
n = int(input[0])
m = int(input[1])
print(min(n, m, (n + m) // 3))


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


(experts, noob) = list(map(int, input().split(' ')))
count = 0
while experts > 0 and noob > 0:
	if experts == 1 and noob == 1:
		break
	if experts >= noob:
		count += 1
		experts -= 2
		noob -= 1
	elif noob > experts:
		noob -= 2
		experts -= 1
		count += 1
print(count)


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


[n, m] = [int(x) for x in input().split(' ')]
teams = 0
while n + m >= 3 and n >= 1 and (m >= 1):
	if n > m:
		n -= 2
		m -= 1
	else:
		n -= 1
		m -= 2
	teams += 1
print(teams)


import math

def prime(n):
	ok = True
	for i in range(2, int(math.sqrt(n))):
		if n % i == 0:
			ok = False
			break
	if ok:
		return True
	else:
		return False

def fact(a, b):
	ans = 1
	for i in range(a, b + 1):
		ans *= i
	return str(ans) - 1

def comb(n, c):
	return fact(n) // (fact(n - c) * c)

def gcd(a, b):
	(a, b) = (max(a, b), min(a, b))
	rem = []
	lst = -1
	while b != 0:
		(a, b) = (b, a % b)
		if b != 0:
			rem.append(b)
	if rem:
		return rem[-1]
	else:
		return a
(a, b) = map(int, input().split())
(a, b) = (max(a, b), min(a, b))
if abs(a - b) < 3:
	(pa, pb) = (a // 3, b // 3)
	ans = min(pa, pb) * 2
	a -= ans * 3 // 2
	b -= ans * 3 // 2
	while a >= 1 and b > 1 or (a > 1 and b >= 1):
		if a > b:
			a -= 2
			b -= 1
			ans += 1
		else:
			b -= 2
			a -= 1
			ans += 1
	print(ans)
elif a >= b * 2:
	print(min(b, a // 2))
else:
	ans = 0
	while a > 1 + b and b:
		dif = abs(a - b)
		a -= dif * 2
		b -= dif
		ans += dif
	(pa, pb) = (a // 3, b // 3)
	ans += min(pa, pb) * 2
	tmp = min(pa, pb) * 2
	a -= tmp * 3 // 2
	b -= tmp * 3 // 2
	while a >= 1 and b > 1 or (a > 1 and b >= 1):
		if a > b:
			a -= 2
			b -= 1
			ans += 1
		else:
			b -= 2
			a -= 1
			ans += 1
	print(ans)


(n, m) = [int(i) for i in input().split()]
ans = 0
while min(n, m) >= 1 and max(n, m) >= 2:
	if n > m:
		n -= 2
		m -= 1
		ans += 1
	else:
		m -= 2
		n -= 1
		ans += 1
print(ans)
exit(0)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial, sqrt
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, permutations
from bisect import *
from functools import reduce
from operator import mul
maxx = float('inf')
I = lambda : int(sys.stdin.buffer.readline())
lint = lambda : [int(x) for x in sys.stdin.buffer.readline().split()]
S = lambda : sys.stdin.readline().strip('\n')
grid = lambda r: [lint() for i in range(r)]
localsys = 0
start_time = time.time()
nCr = lambda n, r: reduce(mul, range(n - r + 1, n + 1), 1) // factorial(r)

def ceill(n, x):
	return (n + x - 1) // x
T = False

def solve():
	(xp, nb) = lint()
	ans = 0
	for i in range(xp + 1):
		(cur, remxp, remn) = (i, (xp - i) // 2, nb - 2 * i)
		if remn >= 0:
			cur += min(remxp, remn)
			ans = max(ans, cur)
	print(ans)

def run():
	if path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
run()
T = I() if T else 1
for _ in range(T):
	solve()


(a, b) = map(int, input().split())
if b > a * 2:
	ans = a
elif a > b * 2:
	ans = b
else:
	ans = int((a + b) / 3)
print(ans)


(a, b) = map(int, input().split())
ans = 0
if a < 1 and b < 2 or (a < 2 and b < 1):
	print(ans)
else:
	for i in range(a + 1):
		ans = max(ans, min((a - i) // 2, b - 2 * i) + i)
	print(ans)


(experienced, amateur) = map(int, input().split())
count = 0
while experienced != 0 and amateur != 0:
	if experienced >= amateur and experienced > 1:
		experienced -= 2
		amateur -= 1
		count += 1
	elif experienced < amateur and amateur > 1:
		experienced -= 1
		amateur -= 2
		count += 1
	else:
		break
print(count)


(n, m) = map(int, input().split())
(a, b) = (min(n, m), max(n, m))
if 2 * a <= b:
	print(a)
	exit()
t = b - a
b = b - 2 * t
a = a - t
ans = t
if a % 3 == 2:
	ans = ans + 2 * (a // 3) + 1
else:
	ans = ans + 2 * (a // 3)
print(ans)


(a, b) = list(map(int, input().split()))
(a, b) = (max(a, b), min(a, b))
ans = min(b, a - b)
a -= ans * 2
b -= ans
if a > 0 and b > 0:
	ans += (a + b) // 3
print(ans)


(n, m) = map(int, input().split())
if n == 0 or m == 0:
	print(0)
elif n / m <= 1 / 2:
	print(n)
elif n / m >= 2:
	print(m)
else:
	print((n + m) // 3)


(a, b) = map(int, input().split())
big = max(a, b)
small = min(a, b)
if big >= 2 * small:
	print(small)
else:
	print((big + small) // 3)


(n, m) = 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)


def main():
	from sys import stdin, stdout
	it = iter(map(int, stdin.read().split()))
	n = next(it)
	m = next(it)
	mn = min(n, m)
	rem = n + m - 2 * mn
	if mn <= rem:
		ans = mn
	else:
		ans = rem
		tmp = mn - rem
		ans += tmp // 3 * 2
		if tmp % 3 == 2:
			ans += 1
	stdout.write(str(ans) + '\n')
main()


(n, m) = map(int, input().split())
cnt = 0
if n == 1 and m == 1:
	print(0)
else:
	while n != 0 and m != 0:
		if n == 1 and m == 1:
			break
		if min(n, m) == n:
			cnt += 1
			n -= 1
			m -= 2
		else:
			cnt += 1
			n -= 2
			m -= 1
	print(cnt)


(a, b) = input().split()
c = int(a) + int(b)
d = c // 3
if d <= min(int(a), int(b)):
	print(d)
else:
	print(min(int(a), int(b)))


(n, m) = map(int, input().split())
count = 0
while min(n, m) >= 1 and max(n, m) >= 2:
	if n > m:
		n -= 2
		m -= 1
		count += 1
	else:
		m -= 2
		n -= 1
		count += 1
print(count)


(a, b) = map(int, input().split())
if a * 2 >= b and a <= b * 2:
	print((a + b) // 3)
else:
	print(min(a, b))


import math, sys
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def isPrime(n):
	if n <= 1:
		return False
	i = 2
	while i ** 2 <= n:
		if n % i == 0:
			return False
		i += 1
	return True

def primeFactors(n):
	factors = []
	i = 2
	while i ** 2 <= n:
		while n % i == 0:
			factors.append(i)
			n //= i
		i += 1
	if n > 1:
		factors.append(n)
	return factors

def vars():
	return map(int, input().split())

def array():
	return list(map(int, input().split()))

def c(n, r):
	return math.factorial(n) / (math.factorial(n - r) * math.factorial(r))

def main():
	(n, m) = vars()
	t = min(n, m)
	print(min(t, (n + m) // 3))
t = 1
for _ in range(t):
	main()


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


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


import sys
from collections import *
import math
input = sys.stdin.readline
(n, m) = [int(x) for x in input().split()]
print(min(n, m, (n + m) // 3))


(n, m) = input().strip().split(' ')
n = int(n)
m = int(m)
ans = min(n, m, (n + m) // 3)
print(ans)


import sys
R = lambda : map(int, input().split())
(n, m) = R()
if 2 * n <= m:
	print(n)
elif 2 * m <= n:
	print(m)
else:
	print((m + n) // 3)


(n, k) = [int(i) for i in input().split()]
print(min((n + k) // 3, n, k))


(n, m) = 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
(e, n) = list(map(int, input().split()))
res = 0
while True:
	if e + n < 3:
		print(res)
		sys.exit()
	if e is 0 or n is 0:
		print(res)
		sys.exit()
	if e < n:
		n = n - 2
		e = e - 1
		res = res + 1
	else:
		e = e - 2
		n = n - 1
		res = res + 1
print(res)


val = list(map(int, input().split(' ')))
n = val[0]
m = val[1]
count = 0
while n != 0 or m != 0:
	if n <= m and n - 1 >= 0 and (m - 2 >= 0):
		n -= 1
		m -= 2
		count += 1
	elif n > m and n - 2 >= 0 and (m - 1 >= 0):
		n -= 2
		m -= 1
		count += 1
	else:
		break
print(count)


(a, b) = map(int, input().split())

def rek(a, b):
	if b > a:
		(a, b) = (b, a)
	res = min(a // 4, b) + (1 if a // 2 % 2 and b - a // 4 > 1 else 0)
	if a >= 2 and b == 1:
		return 1
	if res == 0:
		return 0
	b -= res
	a -= res * 2
	return res + rek(a, b)
print(rek(a, b))


(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)


import sys
import math
import itertools
import collections

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(map(int, input().split()))

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def wr(arr):
	return '\n'.join(map(str, arr))

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
(n, m) = mi()
print(min(m, n)) if n > 2 * m or m > 2 * n else print((n + m) // 3)


(a, b) = [int(i) for i in input().split()]
(a, b) = (min(a, b), max(a, b))
if b / 2 <= a:
	print(int((a + b) / 3))
else:
	print(a)


(a, b) = map(int, input().split())
team = 0
while a >= 3 and b >= 3:
	if a > b:
		a -= 2
		b -= 1
		team += 1
	else:
		a -= 1
		b -= 2
		team += 1
rem = min(a, b)
if rem == 0:
	extra = 0
elif rem == 1:
	if max(a, b) >= 2:
		extra = 1
	else:
		extra = 0
elif rem == 2:
	if max(a, b) < 4:
		extra = 1
	else:
		extra = 2
print(team + extra)


(n, m) = map(int, input().split())
max = 0
while n + m > 2 and n * m != 0:
	if m > n:
		max += 1
		m -= 2
		n -= 1
	elif n > m:
		max += 1
		m -= 1
		n -= 2
	else:
		max += 1
		n -= 1
		m -= 2
print(max)


value = 0
line = str(input()).split()
line = [int(it) for it in line]
line.sort()
if 2 * line[0] > line[1]:
	value += (2 * line[0] - line[1]) * 2 // 3 + (line[1] - line[0])
else:
	value += line[0]
print(value)


import sys

def main():
	(n, m) = map(int, sys.stdin.readline().split())
	answer = 0
	for i in range(min(n + 1, m // 2 + 1)):
		answer = max(answer, i + max(0, min(m - i * 2, (n - i) // 2)))
	print(answer)
main()


(n, m) = map(int, input().split())
ans = 0
while n * m >= 2:
	(n, m) = (min(n, m), max(n, m))
	n -= 1
	m -= 2
	ans += 1
print(ans)


(n, m) = map(int, input().split())
(x, y) = (max(n, m), min(n, m))
z = x // 2
if z > y:
	print(y)
else:
	print((x + y) // 3)


def ansifequal(n):
	if n % 3 == 0:
		return 2 * n // 3
	elif n % 3 == 1:
		return 2 * (n - 1) // 3
	else:
		return 2 * (n + 1) // 3 - 1
listone = input().split()
n = int(listone[0])
m = int(listone[1])
if n == m:
	print(ansifequal(n))
else:
	b = max(n, m)
	s = min(n, m)
	if b > 2 * s:
		print(s)
	else:
		print(b - s + ansifequal(2 * s - b))


(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)


def solve():
	(a, b) = map(int, input().split())
	if a > b:
		(a, b) = (b, a)
	if a * 2 <= b:
		return a
	return (a + b) // 3
print(solve())


def training(n, m):
	t = 0
	for i in range(5 * 10 ** 5):
		if n >= m and n > 1 and (m > 0):
			n -= 2
			m -= 1
			t += 1
		elif n < m and n > 0 and (m > 1):
			n -= 1
			m -= 2
			t += 1
		else:
			return t
(a, b) = list(map(int, input().split(' ')))
print(training(a, b))


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


(g, h) = map(int, input().split())
n = max(g, h)
m = min(g, h)
if g == h:
	n = g
	m = h
a = 0
if n <= 2 * m:
	print((n + m) // 3)
else:
	while n < 2 * m:
		m = m - 1
		a = a + 1
	l = m
	n = n - 2 * m
	m = a
	print(l + min(n, m))


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


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(n, m) = map(int, input().split())
ans = 0
for x in range(min(n, (n + m) // 3) + 1):
	y = min((n - x) // 2, m - 2 * x)
	if y >= 0:
		ans = max(ans, x + y)
print(ans)


(nn, mm) = input().split()
(n, m) = (int(nn), int(mm))
c = 0
while min(n, m) > 0:
	if n == m:
		c += (n + m) // 3
		break
	elif n > m:
		n -= 2
		m -= 1
	else:
		n -= 1
		m -= 2
	c += 1
print(c)


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


from collections import Counter, defaultdict, deque
import sys
input = sys.stdin.readline

def solve():
	(a, b) = [int(x) for x in input().split()]
	ans = 0
	while a > 0 and b > 0:
		if a > b and a > 1:
			a -= 2
			b -= 1
			ans += 1
		elif b > 1:
			b -= 2
			a -= 1
			ans += 1
		if a == b == 1:
			break
	print(ans)
tt = 1
for test in range(tt):
	solve()


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


x = input()
li = x.split(' ')
n = int(li[0])
m = int(li[1])
result = 1
if n * 2 < m:
	result = n
elif m * 2 < n:
	result = m
else:
	result = int((n + m) / 3)
print(result)


(a, b) = [int(s) for s in input().split()]
s = 0
while max(a, b) >= 2 and min(a, b) >= 1:
	if a > b:
		a -= 2
		b -= 1
	else:
		a -= 1
		b -= 2
	s += 1
print(s)


(n, m) = input().strip().split()
n = int(n)
m = int(m)
a = divmod(2 * m - n, 3)[0]
maxa = max(n, divmod(m, 2)[0])
mina = min(n, divmod(m, 2)[0])
if a > maxa:
	a = mina
elif a < 0:
	a = 0
elif a == maxa and maxa > mina:
	a = mina
b = min(m - 2 * a, divmod(n - a, 2)[0])
print(a + b)


(n, m) = map(int, input().split())
x = 0
for i in range(n + 1):
	if 2 * i > m:
		break
	x = max(x, i + min(m - 2 * i, (n - i) // 2))
print(x)


def count_teams(x, y):
	answer = (x + y) // 3
	if answer > min(x, y):
		return min(x, y)
	return answer
(a, b) = map(int, input().split())
print(count_teams(b, a))


import os
import sys
import math
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def dijkstra(start, distance, path, n):
	visited = [False for _ in range(n)]
	distance[start] = 0
	for i in range(n):
		v = -1
		for j in range(n):
			if not visited[v] and (v == -1 or distance[j] < distance[v]):
				v = j
		if distance[v] == math.inf:
			break
		visited[v] = True
		for edge in adj[v]:
			destination = edge[0]
			weight = edge[1]
			if distance[v] + weight < distance[destination]:
				distance[destination] = distance[v] + weight
				path[destination] = v

def gcd(a, b):
	if b == 0:
		return a
	else:
		return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def npr(n, r):
	return math.factorial(n) // math.factorial(n - r)

def seive(n):
	primes = [True] * (n + 1)
	ans = []
	for i in range(2, n):
		if not primes[i]:
			continue
		j = 2 * i
		while j <= n:
			primes[j] = False
			j += i
	for p in range(2, n + 1):
		if primes[p]:
			ans += [p]
	return ans

def factors(n):
	factors = []
	x = 1
	while x * x <= n:
		if n % x == 0:
			if n // x == x:
				factors.append(x)
			else:
				factors.append(x)
				factors.append(n // x)
		x += 1
	return factors

def main():
	try:
		(n, m) = invr()
		ans = 0
		for i in range(n + 1):
			cur = i
			leftn = n - i
			leftm = m - 2 * i
			if leftm >= 0:
				cur += min(leftm, leftn // 2)
				ans = max(ans, cur)
		print(ans)
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


i = [*map(int, input().split())]
[a, b] = [min(i), max(i)]
d = min(b - a, a)
print(int(d + (a - d) * 2 / 3))


(n, m) = map(int, input().split())
tms = 0
if n >= 2 * m:
	tms = m
elif m >= 2 * n:
	tms = n
else:
	while m >= 1 and n > 1 or (m > 1 and n >= 1):
		if n == m:
			tms += (m + n) // 3
			break
		elif n > m:
			tms += 1
			n -= 2
			m -= 1
		elif n < m:
			tms += 1
			n -= 1
			m -= 2
print(tms)


import collections
import math
local = False
if local:
	file = open('B.txt', 'r')

def inp():
	if local:
		return file.readline().rstrip()
	else:
		return input().rstrip()

def ints():
	return [int(_) for _ in inp().split()]
(n, m) = ints()
ans = 0
while max(m, n) >= 2 and min(m, n) >= 1:
	if m >= n:
		m -= 2
		n -= 1
	else:
		n -= 2
		m -= 1
	ans += 1
print(ans)


def inp():
	return map(int, input().split())
(n, m) = inp()
ans = 0
while n and m:
	if n == m == 1:
		break
	if n >= m:
		n -= 2
		m -= 1
	else:
		n -= 1
		m -= 2
	ans += 1
print(ans)


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


(n, m) = list(map(int, input().strip().split()))
count = 0
while n >= 1 and m >= 1:
	if n != 1 or m != 1:
		count += 1
	if n >= m:
		m = m - 1
		n = n - 2
	else:
		m = m - 2
		n -= 1
print(count)


from sys import stdin, stdout
import math
(a, b) = map(int, stdin.readline().split())
count = 0
n = max(a, b)
m = a + b - n
while n > 0 and m > 0:
	if n > m:
		n -= 2
		m -= 1
		count += 1
	elif n == m:
		count += n * 2 // 3
		break
	else:
		n -= 1
		m -= 2
		count += 1
stdout.write(str(count) + '\n')


import sys
import random
from math import log2, log, ceil
input = sys.stdin.readline

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a > 0:
		return gcd(b % a, a)
	return b

def primefs(n):
	if n == 1:
		return 1
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	while x != link[x]:
		x = link[x]
	return x

def union(x, y, size, link):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().split()))
MOD = int(1000000000.0) + 7
CMOD = 998244353
(n, m) = sorted(int_array())
if m >= 2 * n:
	print(n)
	exit()
ans = m - n
n -= ans
ans += 2 * (n // 3)
if n % 3 == 2:
	ans += 1
print(ans)


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


from sys import *
MAXN = 10 ** 5 + 228
MOD = 10 ** 9 + 7
(a, b) = (int(z) for z in input().split())
print(min(a, b, (a + b) // 3))


(n, m) = map(int, input().split())
result = 0
while n > 0 and m > 0:
	if n == 1 and m == 1:
		break
	if n > m:
		diff = min(n - m, n, m)
		n -= 2 * diff
		m -= diff
	elif n < m:
		diff = min(m - n, n, m)
		m -= 2 * diff
		n -= diff
	elif n == 2 and m == 2:
		diff = 1
		m -= 1
		n -= 2
	else:
		diff = m // 3
		m -= diff * 3
		n -= diff * 3
		diff *= 2
	result += diff
print(result)


for t in range(1):
	(n, m) = map(int, input().split())
	ans = 0
	while n > 1 and m >= 1 or (n >= 1 and m > 1):
		if n >= m:
			n -= 2
			m -= 1
			ans += 1
		else:
			n -= 1
			m -= 2
			ans += 1
	print(ans)


import math
s = input().split()
n = int(s[0])
m = int(s[1])
if m < n:
	m = m + n
	n = m - n
	m = m - n

def res():
	if m > 2 * n:
		return n
	return math.trunc(n - (2 * n - m) / 3)
print(res())


def type1(n, m):
	return (n - 2 * min(m, n // 2), m - min(m, n // 2), min(m, n // 2))

def type2(n, m):
	return (n - min(n, m // 2), m - 2 * min(n, m // 2), min(n, m // 2))
(n, m) = map(int, input().split())
(n, m, team) = type1(n, m)
(n, m, team2) = type2(n, m)
team3 = team
team4 = team2
p = n
q = m
while True:
	team -= 1
	n += 2
	m += 1
	(n, m, dt) = type2(n, m)
	if dt > 1 and team >= 0:
		team2 += dt
	else:
		team += 1
		break
a = team + team2
while True:
	team4 -= 1
	p += 1
	q += 2
	(p, q, dt) = type1(p, q)
	if dt > 1 and team4 >= 0:
		team3 += dt
	else:
		team4 += 1
		break
b = team3 + team4
print(max(a, b))


(n, m) = [int(x) for x in input().split()]
t = max(n, m)
v = min(n, m)
if t >= 2 * v:
	print(v)
else:
	print((n + m) // 3)


def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def main():
	(n, m) = mi()
	print(min(n, min(m, (n + m) // 3)))
main()


(n, m) = (int(i) for i in input().split())
(m, n) = (max(m, n), min(m, n))
teams = 0
while m - n > 1 and n > 0:
	t = min(n, (m - n) // 2)
	teams += t
	m -= t * 2
	n -= t
if n > 0:
	teams += (m + n) // 3
print(teams)


(n, m) = map(int, input().split())
k = (n + m) // 3
if k <= m and k <= n:
	print(k)
elif k > m:
	print(m)
else:
	print(n)


st = input()
li = st.split()
for i in range(len(li)):
	li[i] = int(li[i])
a = li[0]
b = li[1]
n = 0
while a >= 2 and b >= 2:
	if a >= b:
		a = a - 2
		b = b - 1
		n = n + 1
	else:
		b = b - 2
		a = a - 1
		n = n + 1
if a == 1 and b > 1:
	n = n + 1
if b == 1 and a > 1:
	n = n + 1
print(n)


(experienced, newbies) = map(int, input().strip().split())
if min([experienced, newbies]) < 1:
	print(0)
	exit()
ratio = min([experienced, newbies]) / (experienced + newbies)
if ratio < 1 / 3:
	print(min([experienced, newbies]))
else:
	print((experienced + newbies) // 3)


(n, m) = map(int, input().split())
import math
if n >= 2 * m or m >= 2 * n:
	print(min(n, m))
else:
	print(math.floor((n + m) / 3))


def main():
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	ctr = 0
	while a > 0 and b > 0:
		if a == b and a >= 2 and (b >= 1):
			a -= 2
			b -= 1
			ctr += 1
		while a > b and a >= 2 and (b >= 1):
			a -= 2
			b -= 1
			ctr += 1
		while a < b and a >= 1 and (b >= 2):
			a -= 1
			b -= 2
			ctr += 1
		if a == b == 1:
			a -= 1
			b -= 1
	print(ctr)
main()


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


[n, m] = list(map(int, input().rstrip().split()))
dontStop = True
count = 0
for i in range(m):
	if n >= m:
		if m - 1 >= 0 and n - 2 >= 0:
			m -= 1
			n -= 2
			count += 1
		elif m - 2 >= 0 and n - 1 >= 0:
			m -= 2
			n -= 1
			count += 1
	elif m - 2 >= 0 and n - 1 >= 0:
		m -= 2
		n -= 1
		count += 1
	elif m - 1 >= 0 and n - 2 >= 0:
		m -= 1
		n -= 2
		count += 1
print(count)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().split())
stdout.write(str(min(n, m, (m + n) // 3)))


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
(n, m) = inm()
print(min(min(n, m), (n + m) // 3))


(n, m) = map(int, input().split())
a = min(n, m)
p = a
n -= a
m -= a
c = 0
leftover = max(n, m)
if leftover >= p:
	print(p)
	exit()
else:
	c = leftover
	p -= leftover
	c += 2 * (p // 3)
	if p % 3 == 2:
		c += 1
	print(c)


(a, b) = map(int, str(input()).split())
result = 0
if a <= 2 * b and b <= 2 * a:
	result = (a + b) / 3
elif a >= 2 * b:
	result = b
else:
	result = a
print(int(result))


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


(n, m) = list(map(int, input().split()))
a = min(n, m)
b = max(n, m)
if b >= 2 * a:
	print(a)
else:
	v = b // 2
	l = a - v
	if l > 1:
		v += 1
	v = max(v, (a + b) // 3)
	print(v)


(n, m) = [int(i) for i in input().split()]
res = 0
while n > 0 and m > 0 and (n + m >= 3):
	res += 1
	if n > m:
		n -= 2
		m -= 1
	else:
		n -= 1
		m -= 2
print(str(res))


(e, n) = map(int, input().split())
ans = 0
while min(e, n) >= 1 and max(e, n) >= 2:
	if e > n:
		e -= 2
		n -= 1
	else:
		e -= 1
		n -= 2
	ans += 1
print(ans)


def ab(n, m):
	c = 0
	while n > 0 and m > 0:
		if n == 1 and m == 1:
			return c + 0
		else:
			if n > m:
				n = n - 2
				m = m - 1
			else:
				m = m - 2
				n = n - 1
			c += 1
	return c
(n, m) = list(map(int, input().split()))
print(ab(n, m))


(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)


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
print(smart(n, m))


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = 0
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = 1
			break
	return ans

def sieve_of_eratosthenes(n):
	ans = []
	arr = [1] * (n + 1)
	(arr[0], arr[1], i) = (0, 0, 2)
	while i * i <= n:
		if arr[i] == 1:
			j = i + i
			while j <= n:
				arr[j] = 0
				j += i
		i += 1
	for k in range(n):
		if arr[k] == 1:
			ans.append(k)
	return ans

def nc2(x):
	if x == 1:
		return 0
	else:
		return x * (x - 1) // 2
for _ in range(1):
	(a, b) = map(int, input().split())
	ans = min(a, b, (a + b) // 3)
	print(ans)


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


(n, m) = map(int, input().split())
d = max(n, m) - min(n, m)
x = d
if n > m:
	n -= d
else:
	m -= d
ans = min(n, m, x)
x -= ans
m -= ans
n -= ans
ans += (n + m) // 3
print(ans)


(n, k) = map(int, input().split(' '))
print(min(n, k, (n + k) // 3))


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


ch = input()
l = ch.split()
n = int(l[0])
m = int(l[1])
i = 0
while True:
	if (n == 0 or m == 0) or (n == 1 and m == 1):
		break
	elif n >= m:
		i = i + 1
		n = n - 2
		m = m - 1
	else:
		n = n - 1
		m = m - 2
		i = i + 1
print(i)


(n, m) = map(int, input().split())
ma = -1
for a in range(n + 1):
	ma = max(ma, a + min((n - a) // 2, m - 2 * a))
print(ma)


def main():
	(e, n) = input().split()
	e = int(e)
	n = int(n)
	count = 0
	while n > 0 and e > 0:
		if e <= n and n >= 2:
			e -= 1
			n -= 2
			count += 1
		elif e > n:
			e -= 2
			n -= 1
			count += 1
		if e == n and e == 1:
			e = 0
	print(count)
main()


(n, m) = map(int, input().split())
ans = 0
for i in range(n + 1):
	ans = max(ans, min((n - i) // 2, m - 2 * i) + i)
print(ans)


import sys, math, string, bisect
input = sys.stdin.readline
from collections import deque
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
(a, b) = M()
print(min(a, b, (a + b) // 3))


import math
import os
import random
import re
import sys
a = list(map(int, input().rstrip().split()))
(n, m, c) = (a[0], a[1], 0)
while n != 0 and m != 0:
	if n > m:
		if n >= 2:
			n = n - 2
			m = m - 1
			c = c + 1
		else:
			break
	elif m >= 2:
		m = m - 2
		n = n - 1
		c = c + 1
	else:
		break
print(c)


(exp, new) = [int(x) for x in input().strip().split()]
teams = 0
while True:
	if exp <= new:
		if exp >= 1 and new >= 2:
			teams += 1
			exp -= 1
			new -= 2
		else:
			break
	elif exp > new:
		if exp >= 2 and new >= 1:
			teams += 1
			exp -= 2
			new -= 1
		else:
			break
print(teams)


from math import ceil
(n, m) = map(int, input().strip().split())
print(min(min(n, m), (n + m) // 3))


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


from sys import stdin as sin

def aint():
	return int(input())

def amap():
	return map(int, sin.readline().split())

def alist():
	return list(map(int, sin.readline().split()))

def astr():
	return input()
(n, m) = amap()
ans = 0
while n >= 1 and m >= 1:
	if n > m:
		ans += 1
		n -= 2
		m -= 1
	elif m > n:
		ans += 1
		n -= 1
		m -= 2
	elif n == m and n > 1:
		ans += 1
		n -= 2
		m -= 1
	else:
		break
print(ans)


def Main(n, m):
	cnt = 0
	while True:
		if n == 1 and m == 1 or n <= 0 or m <= 0:
			break
		if n < m:
			n -= 1
			m -= 2
			cnt += 1
		else:
			n -= 2
			m -= 1
			cnt += 1
	print(cnt)
(n, m) = map(int, input().split())
Main(n, m)


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

def min(m, n):
	if m <= n:
		return m
	else:
		return n

def abs(m):
	if m < 0:
		return -m
	else:
		return m

def max(m, n):
	if m > n:
		return m
	return n
a = min(m, n)
b = max(m, n)
if b >= 2 * a:
	print(a)
elif (n + m) % 3 == 0:
	print((m + n) // 3)
else:
	print((m + n) // 3)


from sys import stdin, stdout
(n, m) = map(int, stdin.readline().strip().split())
t1 = n
t2 = m
t3 = (n + m) // 3
print(min(t1, t2, t3))


(n, m) = map(int, input().rstrip().split(' '))
(n, m) = (min(n, m), max(n, m))
if 2 * n < m:
	r = n
else:
	r = (n + m) // 3
print(r)


(n, m) = map(int, input().strip().split(' '))
a = min(n, m)
b = min((n + m) // 3, a)
print(b)


import sys
from math import ceil
from math import floor
(p, n) = map(int, sys.stdin.readline().strip().split(' '))

def solution(p, n):
	sum = p + n
	groups = 0
	while sum > 2 and (p != 0 and n != 0):
		if p > n:
			p -= 2
			n -= 1
			sum -= 3
		elif n >= p:
			n -= 2
			p -= 1
			sum -= 3
		groups += 1
	print(groups)
solution(p, n)


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


(x, n) = map(int, input().split())
if 2 * x <= n:
	print(x)
elif 2 * n <= x:
	print(n)
else:
	diff = abs(x - n)
	equ = min(x, n) - diff
	if equ % 3 == 2:
		rem = 1
	else:
		rem = 0
	print(diff + 2 * (equ // 3) + rem)


import math
from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
(n, m) = M()
ans = 0
while max(n, m) >= 2 and min(n, m) >= 1:
	ans += 1
	if max(n, m) == n and min(n, m) == m:
		n -= 2
		m -= 1
	else:
		m -= 2
		n -= 1
print(ans)


a = [int(x) for x in input().split()]
a.sort()
print(min(a[0], (a[0] + a[1]) // 3))


import sys
import math
(n, m) = [int(x) for x in sys.stdin.readline().split()]
if n < m:
	if n * 2 >= m:
		print(int((n + m) / 3))
	else:
		print(n)
elif m * 2 >= n:
	print(int((n + m) / 3))
else:
	print(m)


(m, n) = input().split(' ')
m = int(m)
n = int(n)
lb = m // 2
ub = 2 * m
if n >= ub:
	print(m)
elif n <= lb:
	print(n)
else:
	print((m + n) // 3)


(n, m) = map(int, input().split())
a = max(n, m)
b = n + m - a
t = 0
while a > 0 and b > 0:
	if a > b:
		a -= 2
		b -= 1
		t += 1
	elif a == b:
		t += a * 2 // 3
		break
	else:
		a -= 1
		b -= 2
		t += 1
print(t)


I = lambda : list(map(int, input().split()))
(n, m) = I()
print(min(n, m, (n + m) // 3))


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


(n, m) = map(int, input().split())
k = 0
while True:
	if n > m:
		n -= 2
		m -= 1
	else:
		n -= 1
		m -= 2
	if n < 0 or m < 0:
		break
	k += 1
print(k)


nm = [int(i) for i in input().split()]
t = (nm[0] + nm[1]) // 3
if t >= nm[0]:
	if nm[0] * 2 <= nm[1]:
		print(nm[0])
elif t >= nm[1]:
	if nm[1] * 2 <= nm[0]:
		print(nm[1])
else:
	print((nm[0] + nm[1]) // 3)


import itertools
(n, m) = [int(x) for x in input().split()]
if 2 * n <= m or 2 * m <= n:
	print(min(n, m))
else:
	print((n + m) // 3)


(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)


(x, y) = input().split()
x = int(x)
ans = 0
y = int(y)
while y > 0 and x > 0:
	if y > x:
		y = y - 2
		x -= 1
		ans += 1
	else:
		if x == 1:
			ans -= 1
		x = x - 2
		y = y - 1
		ans += 1
print(ans)


import math
__author__ = 'Ismail_A'

def read():
	inputs = input().strip()
	return list(map(int, inputs.split()))

def read_pair():
	return map(int, input().split(' '))
(n, m) = read_pair()
if n > m:
	t = m
	m = n
	n = t
print(min(n, (n + m) // 3))


(a, b) = map(int, input().split())
diff = abs(a - b)
small = min(a, b)
if small - diff >= 0:
	if (small - diff) % 3 == 2:
		print(diff + 2 * ((small - diff) // 3) + 1)
	else:
		print(diff + 2 * ((small - diff) // 3))
else:
	print(small)


(pros, noobs) = list(map(int, input().split()))
resultado = 0
for i in range(pros + 1):
	ac = i
	min_pro = pros - i
	min_noob = noobs - 2 * i
	if min_noob >= 0:
		ac += min(min_noob, min_pro / 2)
		resultado = max(resultado, ac)
print(int(resultado))


(n1, n2) = map(int, input().split())
count = 0
while n1 > 0 and n2 > 0:
	if n1 > n2:
		if n1 - 2 >= 0 and n2 - 1 >= 0:
			n1 -= 2
			n2 -= 1
			count += 1
		else:
			break
	elif n1 - 1 >= 0 and n2 - 2 >= 0:
		n1 -= 1
		n2 -= 2
		count += 1
	else:
		break
print(count)


(n, m) = map(int, input().split())
mx = 0
for i in range(min(n, m // 2) + 1):
	(exp, new) = (n, m)
	exp -= i
	new -= i * 2
	if min(exp // 2, new) + i > mx:
		mx = min(exp // 2, new) + i
print(mx)


import sys
lines = []
for Line in sys.stdin:
	lines.append(Line.rstrip('\n'))
(n, m) = list(map(int, lines[0].split()))
del lines[0]
t = 0
while n > 1 and m > 0 or (n > 0 and m > 1):
	if m > n:
		n -= 1
		m -= 2
	else:
		n -= 2
		m -= 1
	t += 1
print(t)


i = input().split(' ')
e = int(i[0])
n = int(i[1])
a = 0
while e > 0 and n > 0 and (not (e == 1 and n == 1)):
	if e > n:
		e -= 2
		n -= 1
		a += 1
	else:
		e -= 1
		n -= 2
		a += 1
print(a)


s = input()
l = s.split()
a = int(l[0])
b = int(l[1])
count = 0
while a != 0 and b != 0 and (a + b >= 3):
	if a >= b:
		a -= 2
		b -= 1
	else:
		a -= 1
		b -= 2
	count += 1
print(count)


__author__ = 'Andrey'
(n, m) = map(int, input().split())
print(min(n, m, (n + m) // 3))


a = [int(x) for x in input().split()]
if min(a) <= max(a) // 2:
	print(min(a))
else:
	print((a[0] + a[1]) // 3)


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


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def main():
	(a, b) = LI()
	c = (a + b) // 3
	return min(a, b, c)
print(main())


def maxTeams(a, b):
	ans = min((a + b) // 3, min(a, b))
	return ans
inputArray = input().strip().split()
a = int(inputArray[0])
b = int(inputArray[1])
print(maxTeams(a, b))


s = input()
i = 0
while s[i] != ' ':
	i = i + 1
a = int(s[:i])
b = int(s[i + 1:])
c = 0
while a != 0 and b != 0:
	if a == 1 and b == 1:
		break
	if a < b:
		a = a - 1
		b = b - 2
	else:
		a = a - 2
		b = b - 1
	c = c + 1
print(c)


temparr = input()
temparr = temparr.split()
experience = int(temparr[0])
noobie = int(temparr[1])
total = 0
while experience != 0 and noobie != 0:
	if experience >= 1 and noobie <= 0:
		break
	if noobie >= 1 and experience <= 0:
		break
	if noobie == 1 and experience == 1:
		break
	if noobie >= experience:
		noobie -= 2
		experience -= 1
		total += 1
	else:
		experience -= 2
		noobie -= 1
		total += 1
print(total)


(n, m) = map(int, input().split())
if 2 * n <= m:
	print(n)
	exit()
if 2 * m <= n:
	print(m)
	exit()
print((n + m) // 3)


(n, m) = map(int, input().split())
if n * 2 <= m:
	print(n)
elif m * 2 <= n:
	print(m)
else:
	if n > m:
		(n, m) = (m, n)
	a = m // 2
	n = n - a
	if m & 1 and n > 1:
		a += 1
		n -= 2
	print(n // 3 + a)


(n, m) = [int(i) for i in input().split()]
if abs(n - m) <= 3:
	print((n + m) // 3)
elif n >= 2 * m or m >= 2 * n:
	print(min(n, m))
else:
	if (max(n, m) - min(n, m)) // 3 < 3:
		n3 = (max(n, m) - min(n, m)) // 3 - 1
	else:
		n3 = 0
	print((n + m) // 3 - n3)


(n, m) = map(int, input().split())
r = max(n, m) - min(n, m)
d = min(min(n, m), r)
n = max(0, min(n, m) - r)
d += 2 * (n // 3) + int(n % 3 == 2)
print(d)


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