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: EASY

Solutions:
(s1, s2) = input().split()
s1 = int(s1)
s2 = int(s2)
count = 0
while s1 > 0 and s2 > 0:
	if s1 == 1 and s2 == 1:
		break
	count += 1
	if s1 < s2:
		(s1, s2) = (s2, s1)
	s1 -= 2
	s2 += 1
print(count)


import sys
an = list(map(int, input().split()))
t = 0
p1 = max(an)
p2 = min(an)
if p1 == 1 and p2 == 1:
	print(0)
	sys.exit()
while p1 > 0 and p2 > 0:
	if p2 == 100:
		temp = p2
		p2 = p1
		p1 = temp
	p1 -= 2
	p2 += 1
	if p1 <= 2:
		temp = p2
		p2 = p1
		p1 = temp
	t += 1
print(t)


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


(a1, a2) = map(int, input().split(' '))
i = 0
while a1 > 0 and a2 > 0:
	if max(a1, a2) > 1:
		i += 1
	if a1 > a2:
		a1 -= 2
		a2 += 1
	elif a1 <= a2:
		a2 -= 2
		a1 += 1
print(i)


(n, m) = map(int, input().split())
count = 0
while n > 0 and m > 0:
	if n > m:
		n -= 2
		m += 1
	else:
		m -= 2
		n += 1
	if n < 0 or m < 0:
		break
	count += 1
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)


import unittest
from random import randint
from sys import maxsize
import pprint

class StressTest(unittest.TestCase):
	known_values = ((3, 5, 6), (4, 4, 5), (1, 100, 98), (100, 1, 98))

	def test_known_cases(self):
		for (a, b, expected) in self.known_values:
			self.assertEqual(expected, GreedySolution().joysticks(a, b))

	def ptest_all_cases(self):
		while True:
			a = randint(1, 50)
			b = randint(1, 50)
			memo_res = NaiveSolution().joysticks(a, b)
			greedy_res = GreedySolution().joysticks(a, b)
			print(a, b)
			self.assertEqual(memo_res, greedy_res)

class NaiveSolution:

	def joysticks(self, a, b):
		if a < 1 or b < 1:
			return 0
		if not hasattr(self, 'memo'):
			self.memo = {}
		if self.memo.get((a, b)):
			return self.memo.get((a, b))
		self.memo[a, b] = 1 + max(self.joysticks(a + 1, b - 2), self.joysticks(a - 2, b + 1))
		return self.memo[a, b]

class DPSolution:

	def joysticks(self, a, b):
		m = max(a, b) + 3
		dp = [[0 for x in range(m)] for x in range(m)]
		for row in range(2, a + 2):
			for col in range(2, b + 2):
				dp[row][col] = dp[col][row] = 1 + max(dp[row - 2][col + 1], dp[row + 1][col - 2])
		pprint.pprint(dp)
		a += 1
		b += 1
		return dp[a][b]

class GreedySolution:

	def joysticks(self, a, b):
		if a < 2 and b < 2:
			return 0
		minutes = 0
		while a > 0 < b:
			if a <= b:
				a += 1
				b -= 2
			else:
				b += 1
				a -= 2
			minutes += 1
		return minutes
(a, b) = tuple(input().strip().split())
ans = GreedySolution().joysticks(int(a), int(b))
print(ans)


import os
import sys
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 main():
	try:
		(a1, a2) = invr()
		if a1 == 1 and a2 == 1:
			print(0)
			exit()
		s = 0
		while a1 > 0 and a2 > 0:
			s += 1
			if a1 < a2:
				a1 += 1
				a2 -= 2
			else:
				a1 -= 2
				a2 += 1
		print(s)
	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()


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


(a, b) = map(int, input().split())
res = 0
(a, b) = sorted([a, b])
while a > 0 and b > 1:
	t = (b - 1) // 2
	res += t
	a += t
	b -= 2 * t
	(a, b) = sorted([a, b])
	if b == 2:
		res += 1
		break
print(res)


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


import math
lookup = {}

def mx(a1, a2):
	if a1 == 0 or a2 == 0:
		return 0
	elif a1 <= 1 and a2 <= 1:
		return 0
	key = str(a1) + ' ' + str(a2)
	if key not in lookup:
		if min(a1, a2) == a1:
			lookup[key] = mx(a1 + 1, a2 - 2) + 1
		elif min(a1, a2) == a2:
			lookup[key] = mx(a1 - 2, a2 + 1) + 1
	return lookup[key]

def s():
	(a1, a2) = [int(x) for x in input().split(' ')]
	print(mx(a1, a2))
s()


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


from sys import stdin
from collections import deque
tokens = []
tokens_next = 0

def next_str():
	global tokens, tokens_next
	while tokens_next >= tokens.__len__():
		tokens = stdin.readline().split()
		tokens_next = 0
	tokens_next += 1
	return tokens[tokens_next - 1]

def nextInt():
	return int(next_str())
a = nextInt()
b = nextInt()
q = deque()
q.append((a, b, 0))
visited = set()
res = 0
while q:
	c = q.popleft()
	res = max(res, c[2])
	if c in visited:
		continue
	visited.add(c)
	if min(c[0], c[1]) <= 0:
		continue
	if c[0] == 1 and c[1] == 1:
		continue
	elif c[0] == 1 and (not c[1] == 1):
		q.append((c[0] + 1, max(c[1] - 2, 0), c[2] + 1))
	elif c[1] == 1 and (not c[1] == 1):
		q.append((max(0, c[0] - 2), c[1] + 1, c[2] + 1))
	else:
		q.append((max(0, c[0] - 2), c[1] + 1, c[2] + 1))
		q.append((c[0] + 1, max(c[1] - 2, 0), c[2] + 1))
print(res)


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


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


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


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

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

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

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]
(a, b) = read_ints()
play_time = 0
while a * b > 1:
	if a > b:
		(a, b) = (b, a)
	play_time += 1
	a += 1
	b -= 2
print(play_time)


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


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


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


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) = map(int, input().split())
ans = 1 if a1 >= 2 or a2 >= 2 else 0
while a1 >= 3 or a2 >= 3:
	if a1 >= 3:
		a1 -= 2
		a2 += 1
		ans += 1
	elif a2 >= 3:
		a2 -= 2
		a1 += 1
		ans += 1
print(ans)


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


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
d = defaultdict(int)

def dp(x, y):
	if d[x, y] != 0:
		return d[x, y]
	if x <= 0 or y <= 0:
		return 0
	if x >= 2 and y >= 2:
		d[x, y] = max(1 + dp(x + 1, y - 2), 1 + dp(x - 2, y + 1))
		return max(1 + dp(x + 1, y - 2), 1 + dp(x - 2, y + 1))
	if x >= 2:
		d[x, y] = 1 + dp(x - 2, y + 1)
		return 1 + dp(x - 2, y + 1)
	if y >= 2:
		d[x, y] = 1 + dp(x + 1, y - 2)
		return 1 + dp(x + 1, y - 2)
	return 0
(a, b) = M()
print(dp(a, b))


import sys
discharge = 2
charge = 1
controller = input().split()
controller[0] = int(controller[0])
controller[1] = int(controller[1])
controller.sort()
if controller[0] == 1 and controller[1] == 1:
	print(0)
	sys.exit()
timePlayed = 0
while True:
	controller.sort()
	timePlayed += 1
	controller[0] += 1
	controller[1] -= 2
	if controller[0] <= 0 or controller[1] <= 0:
		print(timePlayed)
		break


(x, y) = map(int, input().split())
ans = 0
while x != 0 and y != 0:
	temp1 = x
	temp2 = y
	if temp1 == 1 and temp2 == 1:
		break
	x = min(temp1, temp2)
	y = max(temp1, temp2)
	x = x + 1
	y = y - 2
	ans += 1
print(ans)


import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import accumulate, combinations, combinations_with_replacement, groupby, permutations, product
from math import acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot, log2, pi, radians, sin, sqrt, tan
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

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

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

def instr():
	s = input()
	return list(s[:len(s)])

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

def def_value():
	return 0

def solve(a, b, res):
	if b == 2:
		return res + 1
	if a == 0 or b == 0:
		return res
	sec = (b - 1) // 2
	b = (b - 1) % 2 + 1
	a = a + sec
	return solve(b, a, res + sec)
(a, b) = invr()
if a == 1 and b == 1:
	print(0)
else:
	if a > b:
		(a, b) = (b, a)
	res = solve(a, b, 0)
	print(res)


(a, b) = (int(i) for i in input().split())
s = 0
if a <= 1 and b <= 1:
	print(0)
	exit(0)
while a > 0 and b > 0:
	if a > b:
		b += 1
		a -= 2
	else:
		a += 1
		b -= 2
	s += 1
print(s)


a = [[-3, -1, 0], [-1, -1, 1], [0, 1, 1]]
t = [int(i) for i in input().split()]
if t[0] * t[1] == 1:
	print(0)
else:
	print(t[0] // 3 * 3 + t[1] // 3 * 3 + a[t[0] % 3][t[1] % 3])


def func():
	(charge1, charge2) = list(map(int, input().split()))
	(res, ind) = (0, 0)
	if charge1 == 1 and charge2 == 1:
		return res
	if charge1 < charge2:
		ind = 1
	while 1:
		res += 1
		if ind == 0:
			charge1 -= 2
			charge2 += 1
			if charge1 == 1 or charge1 == 2:
				ind = 1
			elif charge1 <= 0:
				return res
		else:
			charge1 += 1
			charge2 -= 2
			if charge2 == 1 or charge2 == 2:
				ind = 0
			elif charge2 <= 0:
				return res
print(func())


from sys import stdin
(a, b) = map(int, stdin.readline().split())
c = 0
while (a > 0 and b > 0) and (a > 1 or b > 1):
	c += 1
	if a <= b:
		a += 1
		b -= 2
	else:
		a -= 2
		b += 1
print(c)


gi = lambda : list(map(int, input().split(' ')))
(a1, a2) = gi()

def bruteForce(a, b):
	if not (a and b) or a + b < 3:
		return 0
	return 1 + bruteForce(max(a, b) - 2, min(a, b) + 1)
print(bruteForce(a1, a2))


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


z = list(map(int, input().split()))
z.sort()
c = 0
while z[0] > 0 and z[1] > 0:
	while z[0] < z[1] and z[1] > 2:
		z[0] += 1
		z[1] -= 2
		c += 1
	while z[1] <= z[0] and z[0] > 2:
		z[1] += 1
		z[0] -= 2
		c += 1
	if min(z[0], z[1]) == 0 or max(z[0], z[1]) <= 2:
		if max(z[0], z[1]) == 2 and (min(z[0], z[1]) == 1 or min(z[0], z[1]) == 2):
			c += 1
		break
print(c)


from sys import stdin

def get_ints():
	return list(map(int, stdin.readline().strip().split()))
(a, b) = get_ints()
c = 0
if a == b == 1:
	print(0)
	exit()
while a > 0 and b > 0:
	if a > b:
		b += 1
		a -= 2
	else:
		a += 1
		b -= 2
	c += 1
print(c)


(a1, a2) = [int(x) for x in input().split()]
k = 0
flag = 0
if a1 == a2 == 1:
	flag = 1
else:
	while a1 > 0 and a2 > 0:
		if a1 >= a2:
			a2 += 1
			a1 -= 2
		else:
			a2 -= 2
			a1 += 1
		k += 1
if flag == 1:
	print(0)
else:
	print(k)


def d1100_joysticks(a, b):
	if max(a, b) < 2:
		return 0
	if abs(a - b) % 3 == 0:
		return a + b - 3
	else:
		return a + b - 2
[a, b] = map(int, input().split())
result = d1100_joysticks(a, b)
print(result)


while True:
	try:
		(a, b) = map(int, input().split())
		flag = True
		counter = int(0)
		if a == 1 and b == 1:
			print(0)
			continue
		if a == 1 or b >= a:
			tp = int(a)
			a = int(b)
			b = int(tp)
		while a > 0 and b > 0:
			if flag:
				a -= 2
				b += 1
				if a <= 2 and b > 2:
					flag = False
			else:
				b -= 2
				a += 1
				if b <= 2 and a > 2:
					flag = True
			counter += 1
		print(counter)
	except:
		break


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


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


(a, b) = (int(z) for z in input().split())
cnt = 0
while a * b > 1:
	if a > b:
		(a, b) = (b, a)
	a += 1
	b -= 2
	cnt += 1
print(cnt)


(a1, a2) = [int(x) for x in input().split()]
counter = 0
while a1 > 0 and a2 > 0:
	(a1, a2) = (min(a1, a2) + 1, max(a1, a2) - 2)
	counter += 1
print(counter - int(a1 < 0 or a2 < 0))


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


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


readInts = lambda : list(map(int, input().split()))
(a, b) = readInts()
ret = 0
while a > 0 and b > 0:
	if a > b:
		(a, b) = (b, a)
	a += 1
	b -= 2
	if b >= 0:
		ret += 1
print(ret)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
(a1, a2) = get_ints()
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
	else:
		break
print(count)


(a, b) = map(int, input().split())
count = 0
if a >= 2 or b >= 2:
	for i in range(200):
		if b > a:
			a = a + 1
			b = b - 2
			count += 1
		else:
			b = b + 1
			a = a - 2
			count += 1
		if a <= 0 or b <= 0:
			break
print(count)


(a, b) = [int(x) for x in input().split()]
count = 0
while a * b > 1:
	(a, b) = (min(a, b), max(a, b))
	a += 1
	b -= 2
	count += 1
print(count)


(a_1, a_2) = map(int, input().split())
res = 0
if a_1 <= 1 and a_2 <= 1:
	print(0)
else:
	while a_1 > 0 and a_2 > 0:
		if a_1 > a_2:
			a_1 -= 2
			a_2 += 1
		else:
			a_1 += 1
			a_2 -= 2
		res += 1
	print(res)


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


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


import sys
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 list(map(int, input().split()))
hash_map = {}

def solve(a1, a2):
	if a1 <= 0 or a2 <= 0:
		return 0
	if a1 == 1 and a2 == 1:
		return 0
	if a1 <= 2 and a2 <= 2:
		return 1
	if (a1, a2) in hash_map:
		return hash_map[a1, a2]
	hash_map[a1, a2] = max(1 + solve(a1 - 2, a2 + 1), 1 + solve(a1 + 1, a2 - 2))
	return hash_map[a1, a2]
a = inlt()
print(solve(a[0], a[1]))


memo = {}

def f(a, b):
	global memo
	if a <= 0 or b <= 0 or (a == 1 and b == 1):
		return 0
	if (a, b) in memo:
		return memo[a, b]
	x = f(a - 2, b + 1)
	y = f(a + 1, b - 2)
	memo[a, b] = 1 + max(x, y)
	return memo[a, b]
(a, b) = map(int, input().split(' '))
print(f(a, b))


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


def main():
	l = input().split(' ')
	a1 = int(l[0])
	a2 = int(l[1])
	s = a1 + a2
	a1 = min(a1, a2)
	a2 = s - a1
	ans = 0
	while a1 > 0 and a2 > 0:
		a1 += 1
		a2 -= 2
		if a1 >= 0 and a2 >= 0:
			ans += 1
		s = a1 + a2
		a1 = min(a1, a2)
		a2 = s - a1
	print(ans)
main()


(q, w) = map(int, input().split())
z = 0
while q > 0 and w > 0:
	if q == 1 and w == 1:
		break
	elif q < w:
		q += 1
		w -= 2
		z += 1
	else:
		q -= 2
		w += 1
		z += 1
print(z)


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


(a1, a2) = input().split()
(a1, a2) = (int(a1), int(a2))
if a1 == a2 and a1 != 1:
	print(a1 + a2 - 3)
elif a1 == 1 and a2 == 1:
	print(0)
elif abs(a1 - a2) % 3 == 0:
	print(a1 + a2 - 3)
else:
	print(a1 + a2 - 2)


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


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


import sys
import math
import bisect

def solve(A):
	ans = 0
	while min(A) > 0:
		A.sort()
		if A[1] == 1:
			break
		A[0] += 1
		A[1] -= 2
		ans += 1
	return ans

def main():
	(a, b) = map(int, input().split())
	ans = solve([a, b])
	print(ans)
main()


(a, b) = map(int, input().split())
if a == 1 and b == 1:
	print(0)
elif a <= 2 and b <= 2:
	print(1)
else:
	x = 0
	while True:
		if a < b:
			if b > 2:
				if b % 2 != 0:
					x += b // 2
					a += b // 2
					b -= b // 2 * 2
				else:
					x += b // 2 - 1
					a += b // 2 - 1
					b -= (b // 2 - 1) * 2
			else:
				x += 1
				a -= 2
				b += 1
		elif a > 2:
			if a % 2 != 0:
				x += a // 2
				b += a // 2
				a -= a // 2 * 2
			else:
				x += a // 2 - 1
				b += a // 2 - 1
				a -= (a // 2 - 1) * 2
		else:
			x += 1
			b -= 2
			a += 1
		if a <= 2 and b <= 2:
			break
	print(x + 1)


a = 0
z = list(map(int, input().split()))
while 1:
	if z[0] < 1 or z[1] < 1 or z == [1, 1]:
		break
	z = sorted(z)
	z[0] += 1
	z[1] -= 2
	a += 1
print(a)


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


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


__author__ = 'aste'

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


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


(a1, a2) = [int(x) for x in input().split(' ')]
mins = 0
while a1 > 0 and a2 > 0:
	if a1 == 1 and a2 == 1:
		break
	mins += 1
	if a1 == min(a1, a2):
		a1 += 1
		a2 -= 2
	else:
		a2 += 1
		a1 -= 2
print(mins)


(a1, a2) = list(map(int, input().split()))
print(max(0, a1 + a2 - 2 - (abs(a1 - a2) % 3 == 0)))


import sys
(a1, a2) = input().split(' ')
a1 = int(a1)
a2 = int(a2)
t = int(0)
if a1 == 1 and a2 == 1:
	print(0)
else:
	while a1 and a2:
		if a1 <= a2:
			a1 += 1
			a2 -= 2
			t += 1
		else:
			a2 += 1
			a1 -= 2
			t += 1
	print(t)


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


import math, sys, re, itertools
(rs, ri, rai) = (input, lambda : int(input()), lambda : list(map(int, input().split())))
(a, b) = rai()
r = 0
while True:
	if a <= 0 or b <= 0:
		break
	if a >= b:
		if a < 2:
			break
		a -= 2
		b += 1
		r += 1
	else:
		if b < 2:
			break
		b -= 2
		a += 1
		r += 1
print(r)


def main():
	(a, b) = [int(v) for v in input().split()]
	c = 0
	while a > 0 and b > 0:
		c += 1
		if a > b:
			b += 1
			a -= 2
		else:
			b -= 2
			a += 1
		if a < 0 or b < 0:
			c -= 1
			break
	print(c)
main()


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


(a, b) = sorted(list(map(int, input().split())))
i = 0
while a != 0 and b != 0:
	if a < b:
		if b >= 2:
			a += 1
			b -= 2
		elif b == 1:
			b = 0
			continue
		else:
			b = 0
			a += 1
	elif a >= 2:
		b += 1
		a -= 2
	elif a == 1:
		a = 0
		continue
	else:
		a = 0
		b += 1
	i += 1
print(i)


(m, n) = [int(x) for x in input().split()]

def count(m, n):
	cache = dict()
	cache[1, 1] = 0

	def c(i, j):
		p = (i, j)
		if i <= 0 or j <= 0:
			return 0
		if p in cache:
			return cache[p]
		v = 1 + max(c(i - 2, j + 1), c(i + 1, j - 2))
		cache[p] = v
		return v
	return c(m, n)
print(count(m, n))


def main():
	(a, b) = map(int, input().split())
	for t in range(999):
		if a > b:
			(a, b) = (b, a)
		(a, b) = (a + 1, b - 2)
		if b <= 0:
			print(t + (not b))
			return
main()


(a, b) = list(map(int, input().split()))
ans = 0
if a == 1 and b == 1:
	print(0)
	exit()
while a > 0 and b > 0:
	(x, y) = (max(a, b), min(a, b))
	(a, b) = (x, y)
	a -= 2
	b += 1
	if a > 0 and b > 0:
		ans += 1
	else:
		break
print(ans + 1)


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


class A(object):

	def __init__(self):
		self.AC()

	def GetData(self):
		(self.m_A1, self.m_A2) = map(int, input().split())

	def AC(self):
		self.GetData()
		self.m_Ans = self.Slove(self.m_A1, self.m_A2)
		print(self.m_Ans)

	def Slove(self, a1, a2):
		ans = 0
		while (a1 > 1 or a2 > 1) and (a1 != 0 and a2 != 0):
			if a1 > a2:
				a1 -= 2
				a2 += 1
			else:
				a1 += 1
				a2 -= 2
			ans += 1
		return ans
A()


(a1, a2) = map(int, input().split())
(b, c, ans) = (min(a1, a2), max(a1, a2), 0)
while c - b > 1:
	c -= 2
	b += 1
	ans += 1
(b, c) = (min(b, c), max(b, c))
print(0 if b < 2 and c < 2 else ans + (c - 2) * 2 + 1)


(a, b) = map(int, input().split())
print(max(a + b - 2 - ((b - a) % 3 is 0), 0))


(a, b) = map(int, input().split())
x = 0
while (a >= 2 or b >= 2) and a > 0 and (b > 0):
	(a, b) = sorted([a, b])
	a += 1
	b -= 2
	x += 1
print(x)


import sys
(a, b) = map(int, sys.stdin.readline().split())
maximum = max(a, b)
minimum = min(a, b)
solution = 0
if maximum == 100 and minimum > 100:
	solution = 2
	maximum = 99
	minimum = 98
elif maximum == 99 and minimum == 99:
	solution = 1
	maximum = 100
	minimum = 97
difference = maximum - minimum
if difference > 1:
	dividend = difference // 3
	rest = difference % 3
	if rest == 0:
		solution += dividend
		maximum = minimum = minimum + dividend
	elif rest == 1:
		solution += dividend
		minimum += dividend
		maximum = minimum + 1
	else:
		solution += dividend + 1
		maximum = minimum + dividend + 1
		minimum = maximum - 1
solution += (maximum - 2) * 2
solution += 1
print(max(0, solution))


import math
from math import gcd, sqrt, floor, factorial, ceil
from bisect import bisect_left, bisect_right
import bisect
import sys
from sys import stdin, stdout
import os
sys.setrecursionlimit(pow(10, 7))
import collections
from collections import defaultdict, Counter
from statistics import median
input = stdin.readline
from queue import Queue
inf = float('inf')
from operator import neg

def fun(a, b):
	if a <= 1 and b <= 1:
		return -1
	if a > b:
		(a, b) = (b, a)
	return 1 + fun(a + 1, b - 2)
(a, b) = map(int, input().split())
suma = fun(a, b)
if a == 1 and b == 1:
	print(0)
else:
	print(suma)


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


(x, y) = list(map(int, input().split()))
print(max(x + y - 3 + ((y - x) % 3 > 0), 0))


import bisect
line = input()
words = []
for word in line.split():
	words.append(word)
a1 = int(words[0])
a2 = int(words[1])
turns = 0
while 1:
	if a1 <= 0 or a2 <= 0:
		break
	if a1 == 1 and a2 == 1:
		break
	if a1 < a2:
		a1 += 1
		a2 -= 2
	else:
		a2 += 1
		a1 -= 2
	turns += 1
print(turns)


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


inp = input().split()
(a, b) = (int(inp[0]), int(inp[1]))
ans = 0
while a > 0 and b > 0:
	if a < 2 and b < 2:
		break
	ans += 1
	(a, b) = (max(a, b), min(a, b))
	a -= 2
	b += 1
print(ans)


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


def findPos(l, k):
	for (index, i) in enumerate(l):
		if i == k:
			return index
	return -1

def solve(a):
	c = 0
	charger_flag = bool(findPos(a, min(a)))
	null_flag = int(not charger_flag)
	charger_flag = int(charger_flag)
	while True:
		while a[null_flag] > 2 and (not (a[0] <= 0 or a[1] <= 0)):
			a[null_flag] -= 2
			a[charger_flag] += 1
			c += 1
		if a[0] <= 2 and a[1] <= 2:
			if a[0] == 1 and a[1] == 1:
				c -= 1
			break
		aux = null_flag
		null_flag = charger_flag
		charger_flag = aux
	return c + 1
A = [int(i) for i in input().split()]
print(solve(A))


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


q = input().split()
one = int(q[0])
two = int(q[1])
ans = 0
if one == 1 and two == 1:
	print(int(0))
else:
	while one > 0 and two > 0:
		ans += 1
		if one < two:
			two -= 2
			one += 1
		else:
			two += 1
			one -= 2
	print(int(ans))


(a, b) = map(int, input().split())
m = 0
while 1:
	if a <= b:
		a += 1
		b -= 2
		if a < 0 or b < 0:
			break
		m += 1
		if a <= 0 or b <= 0:
			break
	if b < a:
		b += 1
		a -= 2
		if a < 0 or b < 0:
			break
		m += 1
		if a <= 0 or b <= 0:
			break
print(m)


import math
ab = input()
ab = ab.split(' ')
(a, b) = (int(ab[0]), int(ab[1]))
time_played = 0
while a >= 1 and b >= 1:
	if a + b == 2:
		break
	if math.ceil(a / 2) == math.ceil(b / 2):
		if a % 2 == 0:
			a += 1
			b -= 2
			time_played += 1
		else:
			a -= 2
			b += 1
			time_played += 1
	elif math.ceil(a / 2) > math.ceil(b / 2):
		b += 1
		a -= 2
		time_played += 1
	elif math.ceil(a / 2) < math.ceil(b / 2):
		b -= 2
		a += 1
		time_played += 1
print(time_played)


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


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


from collections import defaultdict

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


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


(a1, a2) = map(int, input().split())
t = -1
stop = False
while not stop:
	if a1 == 1 and a2 == 1:
		stop = True
	if a1 <= 0 or a2 <= 0:
		stop = True
	a = min(a1, a2)
	b = max(a1, a2)
	a += 1
	b -= 2
	a1 = a
	a2 = b
	t += 1
print(t)


r = input().split()
a = int(r[0])
b = int(r[1])
c = 0
while a > 2 or b > 2:
	c += 1
	if a > b:
		a -= 2
		b += 1
	else:
		b -= 2
		a += 1
if a == 2 or b == 2:
	c += 1
print(c)


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


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


def swap(n, m):
	if n > m:
		return (n, m)
	return (m, n)

def f(n, m):
	(n, m) = swap(n, m)
	if n <= 0 or m <= 0:
		return 0
	return 1 + f(n - 2, m + 1)
(n, m) = [int(i) for i in input().split()]
if n == 1 and m == 1:
	print(0)
else:
	print(f(n, m))


t = list(map(int, input().split()))
t.sort()
if max(t) < 2 and min(t) < 2:
	print(0)
else:
	for j in range(1, 1000):
		if t[1] > 2:
			t[0] += 1
			t[1] -= 2
		else:
			(t[0], t[1]) = (t[1] + 1, t[0] - 2)
		if min(t) <= 0:
			print(j)
			break


s = input().split()
a = int(s[0])
b = int(s[1])
ans = 0
while a > 0 and b > 0:
	if a == 1 and b == 1:
		break
	if a + b == 3:
		ans += 1
		break
	if a == 2 and b == 2:
		ans += 1
		break
	if a > b:
		t = (a - 1) // 2
		a -= 2 * t
		b += t
		ans += t
	else:
		t = (b - 1) // 2
		b -= 2 * t
		a += t
		ans += t
print(ans)


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

def fun(a, b):
	if max(a, b) == 1:
		return 0
	if max(a, b) == 2:
		return 1
	elif min(a, b) > 2:
		return 1 + fun(min(a, b) - 2, max(a, b) + 1)
	elif min(a, b) == 2 or min(a, b) == 1:
		return 1 + fun(min(a, b) + 1, max(a, b) - 2)
print(fun(a, b))


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) = map(int, input().split())
	print(solve(j1, j2))
main()


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


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


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


from __future__ import print_function
from pprint import *

def battery(a, b):
	count = 0
	while True:
		if a <= 0 or b <= 0 or (a == 1 and b == 1):
			break
		count += 1
		x = min(a, b)
		y = max(a, b)
		a = x + 1
		b = y - 2
	return count
lis = [int(x) for x in input().split()]
print(battery(lis[0], lis[1]))


(a, b) = map(int, input().split(' '))
if a >= b and (a > 1 or b > 1):
	time = 0
	b_bool = True
	while a > 0 and b > 0:
		time += 1
		if b_bool:
			b += 1
			a -= 2
			if a <= 2:
				b_bool = False
		else:
			b -= 2
			a += 1
			if b <= 2:
				b_bool = True
	print(time)
elif b >= a and (a > 1 or b > 1):
	time = 0
	a_bool = True
	while a > 0 and b > 0:
		time += 1
		if a_bool:
			a += 1
			b -= 2
			if b <= 2:
				a_bool = False
		else:
			a -= 2
			b += 1
			if a <= 2:
				a_bool = True
	print(time)
else:
	print(0)


(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())
c = 0
if a == 1 == b:
	print(0)
	exit()
while a > 0 < b:
	k = (min(a, b) + 1) // 2
	c += k
	a -= 2 * k
	b -= 2 * k
	if k == 0:
		break
	else:
		while k > 0:
			if a == min(a, b):
				a += 3
			else:
				b += 3
			k -= 1
print(c)


def solve():
	(a1, a2) = map(int, input().strip().split())
	c = 0
	if a1 == 1 and a2 == 1:
		print(0)
	else:
		while a1 > 0 and a2 > 0:
			(a1, a2) = (max(a1, a2) - 2, min(a1, a2) + 1)
			c += 1
		print(c)
solve()


(i, j) = [int(x) for x in input().split()]
T = 0
while i > 0 and j > 0:
	if i == 1 and j == 1:
		break
	(i, j) = (min(i, j), max(i, j))
	t = j // 2
	if not t > 0:
		T += i
		break
	if 2 * t == j and t > 1:
		t -= 1
	i += t
	j -= 2 * t
	T += t
print(T)


def howlongthegamelasts(x, y):
	if x == y == 1:
		print(x + y - 2)
	elif (x - y) % 3 == 0:
		print(x + y - 3)
	else:
		print(x + y - 2)
(x, y) = [int(x) for x in input().split()]
howlongthegamelasts(x, y)


(m, n) = map(int, input().split())
flag = m > n
count = 0
flag1 = True
while (m != 0 or n != 0) and flag1 == True:
	if m == 1 and n == 1:
		break
	if flag == True:
		while m != 1:
			n += 1
			m -= 2
			count += 1
			if m - 2 == 0 and n > m:
				flag = False
				break
			if m == 0:
				flag1 = False
				break
		else:
			flag = False
	else:
		while n != 1 or n == 0:
			m += 1
			n -= 2
			count += 1
			if n - 2 == 0 and m > n:
				flag = True
				break
			if n == 0:
				flag1 = False
				break
		else:
			flag = True
print(count)


import math
(a, b) = list(map(int, input().split()))
(b, a) = (max(a, b), min(a, b))
if a == 1 and b == 1:
	print(0)
else:
	f = 1
	t = 0
	while True:
		if f == 1:
			if b == 1 or b == 2:
				b = 0
				t += 1
				break
			else:
				x = math.ceil(b / 2) - 1
				b = b - 2 * x
			t += x
			a += x
			f *= -1
		else:
			if a == 1 or a == 2:
				a = 0
				t += 1
				break
			else:
				y = math.ceil(a / 2) - 1
				a = a - 2 * y
			t += y
			b += y
			f *= -1
	print(t)


(n, m) = map(int, input().split())
print(max(n + m - 3 + ((m - n) % 3 > 0), 0))


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


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


import sys
from sys import exit
(a, b) = map(int, input().split(' '))
c = 0
if a <= 1 and b <= 1:
	print(0)
	exit(0)
while 1:
	c = c + 1
	if a <= b:
		a = a + 1
		b = b - 2
	elif a > b:
		b = b + 1
		a = a - 2
	if a <= 0 or b <= 0:
		break
print(c)


def f(a, b):
	if (a, b) in memo.keys():
		return memo[a, b]
	if a <= 0 or b <= 0:
		return 0
	if a == 1 and b == 1:
		return 0
	charge_first = 1 + f(a + 1, b - 2)
	charge_second = 1 + f(a - 2, b + 1)
	memo[a, b] = max(charge_first, charge_second)
	return memo[a, b]
memo = dict()
(a, b) = map(int, input().split())
print(f(a, b))


(a1, a2) = map(int, input().split())
res = 0
while a1 > 0 and a2 > 0:
	if a1 > a2:
		a1 -= 2
		a2 += 1
	else:
		a2 -= 2
		a1 += 1
	if min(a1, a2) >= 0:
		res += 1
if min(a1, a2) > 0 and max(a1, a2) > 2:
	res += 1
print(res)


def solve(a):
	out = 0
	while min(a) > 0 and max(a) > 1:
		out += 1
		i = 0 if a[0] < a[1] else 1
		a[i] += 1
		a[1 - i] -= 2
	print(out)
a = list(map(int, input().split()))
solve(a)


def joyStickSolve(a, b):
	cout = 0
	while a > 0 and b > 0:
		if a == 1 and b == 1:
			break
		if a >= b:
			b += 1
			a -= 2
		elif a < b:
			a += 1
			b -= 2
		cout += 1
	return cout
(a, b) = map(int, input().split())
print(joyStickSolve(a, b))


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

def dpsolver(a, b, dp):
	if (a, b) in dp.keys():
		return dp[a, b]
	elif a <= 1 and b <= 1:
		return 0
	if a == 0 or b == 0:
		return 0
	elif a == 1 or b == 1:
		if a == 1:
			sol = 1 + dpsolver(a + 1, b - 2, dp)
			dp[a, b] = sol
			return sol
		else:
			sol = 1 + dpsolver(a - 2, b + 1, dp)
			dp[a, b] = sol
			return sol
	else:
		sol = 1 + max(dpsolver(a - 2, b + 1, dp), dpsolver(a + 1, b - 2, dp))
		dp[a, b] = sol
		return sol
dp = dict()
print(dpsolver(a, b, dp))


import time
vals = [*map(int, input().split())]
vals.sort()
a = vals[0]
b = vals[1]
times = 0
while True:
	if a == b == 1:
		break
	a += 1
	b -= 2
	if a == 0 or b == 0:
		times += 1
		break
	if a < 0 or b < 0:
		break
	times += 1
	if b <= 2:
		(a, b) = (b, a)
print(times)


(a1, a2) = map(int, input().split())
k = 1
c = 0
while k != 0:
	m1 = min(a1, a2)
	m2 = max(a1, a2)
	if m1 == 0 and m2 == 0 or (m1 == 0 or m2 == 0):
		k = 0
		break
	elif a1 == 1 and a2 == 1:
		break
	else:
		if a1 <= a2:
			a1 += 1
			a2 -= 2
		elif a1 > a2:
			a1 -= 2
			a2 += 1
		c += 1
print(c)


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


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


F = [[0] * 200 for _ in range(200)]
V = [[0] * 200 for _ in range(200)]

def dp(a, b, i=0):
	if a == b == 1:
		return 0
	(a, b) = (min(a, b), max(a, b))
	if a <= 0:
		return 0
	if V[a][b]:
		return F[a][b]
	V[a][b] = 1
	F[a][b] = dp(a + 1, b - 2) + 1
	return F[a][b]

def greedy(a, b):
	i = 0
	while a > 0 and b > 0:
		(a, b) = (min(a, b) + 1, max(a, b) - 2)
		i += 1
	return i
(a, b) = map(int, input().split())
print(dp(a, b))


(m, n) = map(int, input().split())
if m == 1 and n == 1:
	print(0)
elif m <= 2 and n <= 2:
	print(1)
elif (m - n) % 3 == 0:
	print(m + n - 3)
else:
	print(m + n - 2)


a = input().split()
b = int(a[0])
c = int(a[1])

def f(x, y):
	if x * y == 0 or x * y == 1:
		return 0
	elif x < 3 and y < 3:
		return 1
	elif x > 2:
		return 1 + f(x - 2, y + 1)
	else:
		return 1 + f(x + 1, y - 2)
print(f(b, c))


(a1, a2) = [int(x) for x in input().split()]
if a1 == a2 == 1:
	t = 0
elif abs(a1 - a2) % 3 == 0:
	t = a1 + a2 - 3
else:
	t = a1 + a2 - 2
print(t)


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


(z, zz) = (input, lambda : list(map(int, z().split())))
zzz = lambda : [int(i) for i in stdin.readline().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = True
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
(n, m) = zz()
ans = 0
while True:
	(n, m) = sorted([n, m])
	if n >= 1 and m >= 2:
		ans += 1
		n += 1
		m -= 2
	else:
		break
print(ans)


(a, b) = map(int, input().split())
if a < b:
	(a, b) = (b, a)
d = a - b
if b == 0:
	print(0)
	exit(0)
if a <= 1 and b <= 1:
	print(0)
	exit(0)
if d % 3 == 0:
	ch = d // 3
	a = a - 2 * ch
	b = b + ch
	print(ch + (2 * a - 3))
else:
	ch = d // 3
	a = a - 2 * ch
	b = b + ch
	print(ch + a + b - 2)


(a1, a2) = map(int, input().split())
ans = 0
while 1:
	if a1 > a2:
		(a1, a2) = (a2, a1)
	if a2 <= 1 or a1 == 0:
		break
	a1 += 1
	if a1 >= 100:
		a1 = 100
	a2 -= 2
	ans += 1
print(ans)


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


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


import math
(a, b) = map(int, input().split())
c = 0
while 1:
	if a == 0 or b == 0:
		break
	elif a == 1 and b == 1:
		break
	else:
		if a == min(a, b):
			a += 1
			b -= 2
		else:
			b += 1
			a -= 2
		c += 1
print(c)


(a, b) = map(int, input().split())
f = max(a, b)
l = min(a, b)
ans = 0
while f != 0 and l != 0:
	if f == 1 and l == 1:
		break
	f -= 2
	l += 1
	(f, l) = (max(f, l), min(f, l))
	ans += 1
print(ans)


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


z = list(map(int, input().split()))
count = 0
status = True
while z[0] > 0 and z[1] > 0 and status:
	if z[0] < z[1]:
		if z[1] - 2 > 0:
			while z[1] - 2 > 0:
				z[0] += 1
				z[1] -= 2
				count += 1
		else:
			status = False
	elif z[0] - 2 > 0:
		while z[0] - 2 > 0:
			z[1] += 1
			z[0] -= 2
			count += 1
	else:
		status = False
if z[0] == 2 and z[1] == 1:
	print(count + 1)
elif z[0] == 2 and z[1] == 2:
	print(count + 1)
elif z[0] == 1 and z[1] == 2:
	print(count + 1)
else:
	print(count)


from sys import stdin as inp
from sys import stdout as out
(a, b) = map(int, inp.readline().split())
c = 0
if a <= 1 and b <= 1:
	out.write('0')
	exit()
while a > 0 and b > 0:
	if a < b:
		a += 1
		b -= 2
	else:
		b += 1
		a -= 2
	c += 1
out.write(str(c))


pwr = [int(x) for x in input().split()]
pwr.sort()
mins = 0
while pwr[1] - pwr[0] > 2:
	pwr[0] += 1
	pwr[1] -= 2
	mins += 1
while sum(pwr) > 4:
	pwr[0] -= 1
	pwr[1] -= 1
	mins += 2
if sum(pwr) == 4:
	if pwr[0] == 2:
		mins += 1
	else:
		mins += 2
elif sum(pwr) == 3:
	mins += 1
print(mins)


(p, q) = map(int, input().split())
res = 0
while p > 1 or q > 1:
	res += 1
	(p, q) = (min(p, q) + 1, max(p, q) - 2)
	if p == 0 or q == 0:
		break
print(res)


(a1, a2) = map(int, input().split())
r = 0
while a1 > 1 or a2 > 1:
	if a1 >= a2:
		a1 -= 2
		a2 += 1
	else:
		a2 -= 2
		a1 += 1
	r += 1
print(max(0, r - 1))


from bisect import bisect_right as br
import sys
from collections import *
from math import *
import re

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
	c = 0
	for i in range(2, n):
		if prime[i]:
			c += 1
	return c

def iseven(n):
	return [False, True][0 if n % 2 else 1]

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

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

def lcm(a, b):
	return a * b / gcd(a, b)
max_int = sys.maxsize
mod = 10 ** 9 + 7
(a1, a2) = inp()
res = 0
while a1 > 0 and a2 > 0:
	if a1 <= a2:
		a1 += 1
		a2 -= 2
		if a2 >= 0:
			res += 1
	else:
		a2 += 1
		a1 -= 2
		if a1 >= 0:
			res += 1
print(res)


(a, b) = map(int, input().split())
c = abs(a - b)
print([c // 3 + (min(a, b) + c // 3 - 1) * 2 + c % 3 - (c % 3 == 0), 0][max(a, b) < 2])


import sys
(a1, a2) = map(int, sys.stdin.readline().split())
res = 0
while a1 + a2 > 2 and a1 != 0 and (a2 != 0):
	(t1, t2) = (a1, a2)
	a1 = min(t1, t2) + 1
	a2 = max(t2, t1) - 2
	res += 1
print(res)


(a, b) = map(int, input().split())
minutes = 0
cha = True
chb = False
stop = False
while not stop:
	if a == 0 or b == 0:
		stop = True
		break
	if a == 1 and b == 1:
		stop = True
		break
	if a <= 2 and b > 1:
		cha = True
		chb = not cha
	if b <= 2 and a > 1:
		chb = True
		cha = not chb
	if cha:
		a += 1
		b -= 2
	else:
		a -= 2
		b += 1
	if not stop:
		minutes += 1
print(str(minutes))


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


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


import math, re, sys, string, operator, functools, fractions, collections
sys.setrecursionlimit(10 ** 7)
RI = lambda x=' ': list(map(int, input().split(x)))
RS = lambda x=' ': input().rstrip().split(x)
dX = [-1, 1, 0, 0, -1, 1, -1, 1]
dY = [0, 0, -1, 1, 1, -1, -1, 1]
mod = int(1000000000.0 + 7)
eps = 1e-06
pi = math.acos(-1.0)
MAX = 20
(a, b) = RI()
ans = 0
while a and b:
	if a > b:
		(a, b) = (b, a)
	if b == 1:
		break
	ans += 1
	a += 1
	b -= 2
print(ans)


x = sorted(list(map(int, input().split(' '))))
count = 0
while x[0] >= 1 and x[1] > 1:
	x[0] += 1
	x[1] -= 2
	x.sort()
	count += 1
print(count)


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


def solve():
	(first, second) = map(int, input().split())
	count = 0
	while first > 0 and second > 0:
		if check_bigger(first, second):
			first -= 2
			second += 1
		else:
			first += 1
			second -= 2
		if first >= 0 and second >= 0:
			count += 1
	print(count)

def check_bigger(a, b):
	if a > b:
		return True
	else:
		return False
solve()


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)


def fun(a, b):
	if a <= 1 and b <= 1:
		return 0
	cnt1 = (b - a + 1) // 3
	(a, b) = (min(a, b) + cnt1, max(a, b) - 2 * cnt1)
	return cnt1 + 2 * ((a + b - 1) // 2) - 1
(a, b) = map(int, input().split())
print(fun(a, b))


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


(a1, a2) = map(int, input().split())
min_ = 0
while a1 > 0 and a2 > 0:
	if a2 > 2:
		n = a2 // 2
		if a2 % 2 == 0:
			n -= 1
		min_ += n
		a1 += n
		a2 -= 2 * n
	elif a1 > 2:
		n = a1 // 2
		if a1 % 2 == 0:
			n -= 1
		min_ += n
		a2 += n
		a1 -= 2 * n
	else:
		if a1 == 2 or a2 == 2:
			min_ += 1
		a1 -= 2
		a2 -= 2
print(min_)


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


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


(first, second) = map(int, input().split())
count = 0
while first > 0 and second > 1 or (second > 0 and first > 1):
	if first < second:
		first += 1
		second -= 2
	else:
		first -= 2
		second += 1
	count += 1
print(count)


(a, b) = map(int, input().split())
ans = 0
while (a > 1 or b > 1) and a != 0 and (b != 0):
	ma = max(a, b)
	mb = min(a, b)
	if ma == mb == 100:
		a = ma - 2
		b = mb
		ans += 1
		continue
	if ma == 100 and mb != 100:
		a = ma - 2
		b = mb + 1
		ans += 1
		continue
	ma -= 2
	mb += 1
	ans += 1
	a = ma
	b = mb
print(ans)


def maxMin(a, b):
	dp = [[0] * 101] * 101
	if a == 0 or b == 0:
		return 0
	if a == 1 and b == 1:
		return 0
	if a == 1 and b > 1:
		return 1 + maxMin(a + 1, b - 2)
	if a > 1 and b == 1:
		return 1 + maxMin(a - 2, b + 1)
	if b > a:
		(a, b) = (b, a)
	return 1 + maxMin(a - 2, b + 1)
(a, b) = map(int, input().split())
ans = maxMin(a, b)
print(ans)


(joya, joyb) = sorted(map(int, str(input()).split(' ')))
if joya <= 1 and joyb <= 1:
	passit = True
else:
	passit = False
(charge, count) = (0, 0)
if not passit:
	while joya > 0 and joyb > 0:
		count += 1
		if charge == 0:
			joya += 1
			joyb -= 2
		if charge == 1:
			joyb += 1
			joya -= 2
		if joya <= 2:
			charge = 0
		elif joyb <= 2:
			charge = 1
print(count)


def solution(a, b):
	if a < b:
		(a, b) = (b, a)
	if a <= 2 and b <= 2:
		return 1
	x = 0
	if a % 2 == 0:
		x = a // 2 - 1
		a = 2
	else:
		x = a // 2
		a = 1
	b += x
	return x + solution(a, b)
str = input().split()
a = int(str[0])
b = int(str[1])
if a <= 1 and b <= 1:
	print(0)
else:
	res = solution(a, b)
	print(res)


(a1, a2) = map(int, input().split())
ans = 0
while a1 > 2 or a2 > 2:
	(a1, a2) = (min(a1, a2), max(a1, a2))
	if a2 % 2 != 0:
		t1 = a2 // 2
		a2 = 1
	else:
		t1 = a2 // 2 - 1
		a2 = 2
	a1 += t1
	ans += t1
if a1 == 2 or a2 == 2:
	ans += 1
print(ans)


import sys
charges = []
charges_line = sys.stdin.readline().split()
for charge in charges_line:
	charges.append(int(charge))

def max_minutes(x, y):
	if x == 0 or y == 0:
		return 0
	if x == 1 and y == 1:
		return 0
	if x >= y:
		return 1 + max_minutes(x - 2, y + 1)
	return 1 + max_minutes(x + 1, y - 2)
sys.stdout.write(str(max_minutes(charges[0], charges[1])) + '\n')


lst = list(map(int, input().rstrip().split()))
a1 = lst[0]
a2 = lst[1]
time = 0
while a1 > 0 and a2 > 0:
	if a1 == 1 and a2 == 1:
		break
	if a1 >= a2:
		a1 -= 2
		a2 += 1
	elif a1 < a2:
		a1 += 1
		a2 -= 2
	time += 1
print(time)


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


import sys
(a1, a2) = (int(i) for i in input().split())
if a1 == 1 and a2 == 1:
	print(0)
	sys.exit()
if a1 == 100 and a2 == 100:
	(k, a1, a2) = (1, 98, 100)
else:
	k = 0
while min(a1, a2) > 0:
	if a1 <= a2:
		a1 += 1
		a2 -= 2
	else:
		a2 += 1
		a1 -= 2
	k += 1
print(k)


n = list(map(int, input().split()))
first_d = n[0]
second_d = n[1]
k = 0
if first_d == 1 and second_d == 1:
	k = 0
else:
	while first_d > 0 and second_d > 0:
		if first_d > second_d:
			first_d -= 2
			second_d += 1
		else:
			first_d += 1
			second_d -= 2
		k += 1
print(k)


(a, b) = (int(x) for x in input().split())
dp = [[0 for c in range(201)] for r in range(201)]
dp[1][1] = 0
dp[2][1] = 1
dp[2][2] = 1
dp[1][2] = 1
dp[1][3] = 2
dp[3][1] = 2
for sm in range(5, 201):
	dp[1][sm - 1] = dp[2][sm - 3] + 1
	for i in range(2, sm - 1):
		dp[i][sm - i] = max(dp[i - 2][sm - i + 1], dp[i + 1][sm - i - 2]) + 1
	dp[sm - 1][1] = dp[sm - 3][2] + 1
print(dp[a][b])


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


try:
	(a, b) = map(int, input().split())
	c = 0
	if a == 1 and b == 1:
		a = 0
		b = 0
	while a > 0 and b > 0:
		if b > a:
			a = a + 1
			b = b - 2
			c += 1
		elif a > b:
			a = a - 2
			b += 1
			c += 1
		elif a == b:
			a = a - 2
			b = b + 1
			c += 1
	print(c)
except:
	pass


(a, b) = [int(i) for i in input().split()]
x = min(a, b)
y = max(a, b)
time = 0
while x > 0 and y > 0:
	if y > 2:
		if y & 1:
			a = y // 2
			y = 1
		else:
			a = (y - 2) // 2
			y = 2
		time += a
		x += a
	if x > 2:
		if x & 1:
			a = x // 2
			x = 1
		else:
			a = (x - 2) // 2
			x = 2
		y += a
		time += a
	if x <= 2 and y <= 2:
		time += max(y, x) // 2
		x = 0
		y = 0
print(time)


a = input().split(' ')
a1 = int(a[0])
a2 = int(a[1])
ans = 0
while a1 > 0 and a2 > 0:
	if a1 > a2:
		a1 -= 2
		a2 += 1
	else:
		a1 += 1
		a2 -= 2
	if a1 >= 0 and a2 >= 0:
		ans += 1
print(ans)


l = list(map(int, input().split()))
if l[0] == 1 and l[1] == 1:
	print(0)
else:
	c = 0
	while l[0] > 0 and l[1] > 0:
		c += 1
		a = l.index(max(l))
		l[a] -= 2
		l[1 - a] += 1
	print(c)


def joystiki(a, b):
	count = 0
	while a > 0 and b > 0:
		if a == 1 and b == 1:
			break
		elif a > b:
			a -= 2
			b += 1
			count += 1
		else:
			b -= 2
			a += 1
			count += 1
	return count
(A, B) = [int(i) for i in input().split()]
print(joystiki(A, B))


def counter(a1, a2):
	mins = 0
	while a1 != 0 and a2 != 0:
		if a1 == 1 and a2 <= 1:
			break
		if a2 == 1 and a1 <= 1:
			break
		if a1 < a2:
			a1 += 1
			a2 -= 2
		elif a2 < a1:
			a1 -= 2
			a2 += 1
		else:
			a1 += 1
			a2 -= 2
		mins += 1
	return mins
(a1, a2) = list(map(int, input().split(' ')))
print(counter(a1, a2))


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


(a, b) = list(map(int, input().split()))
k = 0
while a > 0 and b > 0:
	if a == 1 and b == 1:
		break
	elif set([a, b]).issubset({1, 2}):
		k += 1
		break
	elif a >= b:
		b += (a - 1) // 2
		k += (a - 1) // 2
		a -= (a - 1) // 2 * 2
	else:
		a += (b - 1) // 2
		k += (b - 1) // 2
		b -= (b - 1) // 2 * 2
print(k)


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


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


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


def main():
	(a1, a2) = list(map(int, input().split()))
	if a1 == 1 and a2 == 1:
		c = 0
	else:
		(a1, a2) = (max(a1, a2), min(a1, a2))
		c = 1
		while a1 != 1 and a1 != 2:
			a1 -= 2
			a2 += 1
			c += 1
			if a1 == 1 or a1 == 2:
				(a1, a2) = (a2, a1)
	print(c)
main()


(x, y) = map(int, input().split())
i = 0
while x > 0 and y > 0:
	(x, y) = (min(x, y) + 1, max(x, y) - 2)
	if not (x >= 0 and y >= 0):
		break
	i += 1
print(i)


(a, b) = map(int, input().split())
sec = 0
if a == 1 and b == 1:
	print(0)
else:
	while True:
		mn = min(a, b)
		mx = max(a, b)
		a = mn
		b = mx
		a += 1
		b -= 2
		sec += 1
		if a <= 0 or b <= 0:
			break
	print(sec)


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


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


(a1, a2) = map(int, input().split())
mn = min(a1, a2)
mx = max(a1, a2)
time = 0
if a1 == 1 and a2 == 1:
	print(0)
else:
	while mn > 0 and mx > 0:
		time += 1
		mn += 1
		mx -= 2
		x = min(mn, mx)
		y = max(mn, mx)
		mn = x
		mx = y
	print(time)


(a, v) = (sorted(map(int, input().split())), 0)
while a[0] > 0 and a[1] > 1:
	(a, v) = (sorted((a[0] + 1, a[1] - 2)), v + 1)
print(v)


def joystick(a1, a2):
	total_minute = 0
	if a1 == 1 and a2 == 1:
		return 0
	while a1 > 0 and a2 > 0:
		if a1 < a2:
			a1 = a1 + 1
			a2 = a2 - 2
			total_minute = total_minute + 1
		else:
			a1 = a1 - 2
			a2 = a2 + 1
			total_minute = total_minute + 1
	return total_minute
(x, y) = map(int, input().split())
print(joystick(x, y))


def game(a, b, count):
	if a == 0 or b == 0:
		return count
	else:
		mi = min(a, b)
		ma = max(a, b)
		return game(mi + 1, ma - 2, count + 1)
(a, b) = map(int, input().split())
if a < 2 and b < 2:
	print(0)
else:
	res = game(a, b, 0)
	print(res)


(a, b) = sorted(map(int, input().split()))
res = 0
while a > 2 or b > 2:
	(x, y) = divmod(b, 2)
	if y == 0:
		x -= 1
		y = 2
	a += x
	res += x
	b = y
	(a, b) = sorted([a, b])
if a > 1 or b > 1:
	res += 1
print(res)


[a1, a2] = list(map(int, input().split(' ')))
result = 0
while a1 * a2 > 1:
	if a1 > a2:
		(a1, a2) = (a2, a1)
	result += 1
	a1 += 1
	a2 -= 2
print(result)


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


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


L = [int(s) for s in input().split()]

def time(a, b):
	if a <= 1 and b <= 1:
		return 0
	if a <= 2 and b <= 2:
		return 1
	if a <= 2:
		return 1 + time(a + 1, b - 2)
	if b <= 2:
		return 1 + time(a - 2, b + 1)
	else:
		return 1 + time(max(a, b) - 2, min(a, b) + 1)
print(time(L[0], L[1]))


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


(a1, a2) = map(int, input().split())
t = 0
while a1 > 0 and a2 > 0:
	if a1 == 1 and a2 == 1:
		break
	(a1, a2) = (min(a1, a2), max(a1, a2))
	a1 += 1
	a2 -= 2
	t += 1
print(t)


def fun():
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	t = 0
	if a == 1 and b == 1:
		return 0
	while 1:
		if a <= 0 or b <= 0:
			return t
		if a < b:
			a += 1
			b -= 2
			t += 1
		else:
			b += 1
			a -= 2
			t += 1
print(fun())


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


(a, b) = map(int, input().split())
res = 0
while a > 0 or b > 0:
	if a > 2:
		res += (a - 1) // 2
		b += (a - 1) // 2
		a %= 2
		if a == 0:
			a = 2
	elif b > 2:
		res += (b - 1) // 2
		a += (b - 1) // 2
		b %= 2
		if b == 0:
			b = 2
	else:
		res += max(a, b) // 2
		break
print(res)


(a, b) = [int(x) for x in input().split()]
d = {}

def f(a, b):
	if a == 0 or b == 0:
		return 0
	if b < a:
		(b, a) = (a, b)
	if (a, b) in d:
		return d[a, b]
	if a == b:
		if a < 2:
			d[a, b] = 0
		else:
			d[a, b] = 2 * a - 3
	else:
		d[a, b] = 1 + f(a + 1, b - 2)
	return d[a, b]
print(f(a, b))


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


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


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


def fun(a, b):
	if a <= 1 and b <= 1:
		return 0
	(a, b) = (min(a, b), max(a, b))
	cnt = 0
	while abs(a - b) > 1:
		a += 1
		b -= 2
		cnt += 1
	return cnt + 2 * ((a + b - 1) // 2) - 1
(a, b) = map(int, input().split())
print(fun(a, b))


(a, b) = map(int, input().split())
print(max(0, a + b - 2 - (abs(a - b) % 3 == 0)))


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


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


[a, b] = list(map(int, input().split(' ')))
if a < b:
	(a, b) = (b, a)

def f(a, b):
	if a < b:
		(a, b) = (b, a)
	return a // 2 if a < 3 else (a - 1) // 2 + f(b + (a - 1) // 2, a - (a - 1) // 2 * 2)
print(f(a, b))


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


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


datos = list(str(input()).split())
datos[0] = int(datos[0])
datos[1] = int(datos[1])
contador = 0
if datos[0] > 1 or datos[1] > 1:
	while datos[0] > 0 and datos[1] > 0:
		if datos[0] >= datos[1]:
			datos[0] -= 2
			datos[1] += 1
			contador += 1
		else:
			datos[0] += 1
			datos[1] -= 2
			contador += 1
print(contador)


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


(a, b) = sorted(map(int, input().split()))
t = 0
while a > 0 and b > 1:
	t += 1
	(a, b) = sorted([min(a, b) + 1, max(a, b) - 2])
print(t)


class Solution(object):

	def __init__(self):
		pass

	def sol(self, p, q):
		r = self.max_times(p, q, {})
		if r <= 0:
			return 0
		return r

	def max_times(self, p, q, dp):
		if p == 0 or q == 0:
			return 0
		if p < 0 or q < 0:
			return -(1 << 30)
		if (p, q) in dp:
			return dp[p, q]
		r = max(self.max_times(p - 2, q + 1, dp), self.max_times(p + 1, q - 2, dp)) + 1
		dp[p, q] = r
		return r

def main():
	sol = Solution()
	p = [int(e) for e in input().split()]
	print(sol.sol(p[0], p[1]))
	return 0
main()


(x, y) = list(map(int, input().split()))
(x, y) = (max(x, y), min(x, y))
d = (x - y) // 3
x -= 2 * d
y += d
if x == y == 1:
	print(d)
elif x == y or x == y + 1:
	print(d + x * 2 - 3)
else:
	print(d + y * 2)


(a, b) = sorted(list(map(int, input().split())))
c = 0
while a > 0 and b > 1:
	c += 1
	(a, b) = sorted([min(a, b) + 1, max(a, b) - 2])
print(c)


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


(a, b) = map(int, input().split())
c = 0
p = a
q = b
while a > 0 and b > 0:
	a1 = a
	b1 = b
	if a > b:
		if a % 2:
			b += a // 2
			c += a // 2
			a = 1
		else:
			c += a // 2 - 1
			b += a // 2 - 1
			a = 2
	elif b % 2:
		a += b // 2
		c += b // 2
		b = 1
	else:
		c += b // 2 - 1
		a += b // 2 - 1
		b = 2
	if a1 == a and b1 == b or (a1 == b and b1 == a):
		break
if p <= 1 and q <= 1:
	print(0)
else:
	print(c + 1)


(x, y) = [int(x) for x in input().split()]
res = 0
if x == 1 and y == 1:
	pass
else:
	while x > 0 and y > 0:
		if x < y:
			x += 1
			y -= 2
			res += 1
		else:
			x -= 2
			y += 1
			res += 1
print(res)


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

def dp(s, mem={}):
	m = mem.get(s)
	if m is not None:
		return m
	(a, b) = s
	if a <= 0 or b <= 0:
		mem[s] = 0
	elif a <= 1 and b <= 1:
		mem[s] = 0
	elif a <= 1:
		if b - 2 < 0:
			mem[s] = 0
		else:
			mem[s] = 1 + dp((a + 1, b - 2))
	elif b <= 1:
		if a - 2 < 0:
			mem[s] = 0
		else:
			mem[s] = 1 + dp((a - 2, b + 1))
	else:
		s1 = (a + 1, b - 2)
		s2 = (a - 2, b + 1)
		mem[s] = max(1 + dp(s1), 1 + dp(s2))
	return mem[s]
print(dp((a, b)))


(C1, C2) = map(int, input().split())
time = 0
while (C1 > 1 or C2 > 1) and (C1 > 0 and C2 > 0):
	if C1 < C2:
		C1 += 1
		C2 -= 2
		time += 1
	else:
		C2 += 1
		C1 -= 2
		time += 1
print(time)


from sys import stdin
(a, b) = map(int, stdin.readline().rstrip().split(' '))
secs = 0
if a < 2 and b < 2:
	print(secs)
else:
	while a > 0 and b > 0:
		secs += 1
		if a > b:
			a -= 2
			b += 1
		else:
			b -= 2
			a += 1
	print(secs)


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


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


(a1, a2) = sorted(map(int, input().split()))
if a1 == 1 and a2 == 1:
	print(0)
else:
	count = 0
	while a1 > 0 and a2 > 0:
		x = a1 + 1
		y = a2 - 2
		a1 = min(x, y)
		a2 = max(x, y)
		count += 1
	print(count)


(P1, P2) = map(int, input().split())
an = 0
while P1 > 0 and P2 > 0:
	if P1 > P2:
		P1 -= 2
		P2 += 1
	else:
		P2 -= 2
		P1 += 1
	if P1 >= 0 and P2 >= 0:
		an += 1
print(an)


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


x = list(map(int, input().split()))
charge = 0
if x[0] > x[1]:
	charge = 1
t = 0
while 0 != min(x) and 1 != max(x):
	for i in range(len(x)):
		if i == charge:
			x[i] += 1
		else:
			x[i] -= 2
	t += 1
	charge = x.index(min(x))
print(t)


(a1, a2) = map(int, input().split())
if a1 == a2 == 1:
	print(0)
	quit()
if a1 > a2:
	(a1, a2) = (a2, a1)
t = 0
while a1 > 0:
	a1 += 1
	a2 -= 2
	t += 1
	if a1 > a2:
		(a1, a2) = (a2, a1)
print(t)


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


import math
(a, b) = map(int, input().split())
m = max(a, b)
mi = min(a, b)
charge = 1
game = -2
ans = 0
while m > 1 or (mi > 1 and (m < 100 or mi < 100)):
	if m == 1 or m - 2 == 0:
		(mi, m) = (m, mi)
	mi += charge
	m += game
	if m <= 0 or mi <= 0:
		ans += 1
		break
	else:
		ans += 1
print(ans)


def run(a1, a2):
	count = 0
	while a1 > 0 and a2 > 0:
		if a1 > a2:
			a1 -= 2
			a2 += 1
		else:
			a1 += 1
			a2 -= 2
		if a1 >= 0 and a2 >= 0:
			count += 1
		else:
			break
	print(count)
a = input().split()
x = int(a[0])
y = int(a[1])
run(x, y)


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


def single():
	return int(input())

def multiple():
	return list(map(int, input().split()))
(a, b) = multiple()
res = 0
while a > 0 and b > 0:
	if a >= b and a >= 2:
		a -= 2
		b += 1
	elif b >= 2:
		a += 1
		b -= 2
	else:
		break
	res += 1
print(res)


(a, b) = map(int, input().split())
max_num = max(a, b)
min_num = min(a, b)
ans = 0
while min(max_num, min_num) > 0:
	min_num += 1
	max_num -= 2
	(max_num, min_num) = (max(max_num, min_num), min(max_num, min_num))
	if min_num < 0:
		break
	ans += 1
print(ans)


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


(a, b) = map(int, input().split())
if (a - b) % 3 == 0:
	print(max(a - 2 + b - 2 + 1, 0))
else:
	print(a + b - 2)


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


X = sorted(list(map(int, input().split())))
c = 0
while X[0] >= 1 and X[1] > 1:
	X[1] -= 2
	X[0] += 1
	X.sort()
	c += 1
print(c)


def most_common(lst):
	return max(set(lst), key=lst.count)
(a1, a2) = [int(x) for x in input().split()]
minu = 0
while True:
	minu += 1
	if a1 == 1 and a2 == 1 or (a1 <= 0 or a2 <= 0):
		break
	elif a1 <= 2:
		a1 += 1
		a2 -= 2
	elif a2 <= 2:
		a2 += 1
		a1 -= 2
	elif a1 <= a2:
		a1 += 1
		a2 -= 2
	else:
		a1 -= 2
		a2 += 1
print(minu - 1)


from collections import defaultdict
from sys import stdin, stdout
(n, k) = map(int, stdin.readline().split())
ans = 0
while (n != 1 or k != 1) and n != 0 and (k != 0):
	if n > k:
		k += 1
		n -= 2
	else:
		n += 1
		k -= 2
	ans += 1
print(ans)


a = list(map(int, input().split(' ')))
n = a[0]
m = a[1]
total = 0
while n > 0 and m > 0:
	if n <= m:
		n = n + 1
		m = m - 2
	elif m < n:
		m = m + 1
		n = n - 2
	if n >= 0 and m >= 0:
		total = total + 1
print(total)


(i, j) = map(int, input().split())
t = 0
while True:
	if i == 1 and j == 1:
		break
	k = min(i, j)
	if k == i:
		i = i + 1
		j = j - 2
	else:
		j = j + 1
		i = i - 2
	t = t + 1
	if i <= 0 or j <= 0:
		break
print(t)


import sys
(a1, a2) = map(int, sys.stdin.readline().split())

def get(x, y):
	if x > 2:
		k = (x - 1) // 2
		return k + get(x - 2 * k, y + k)
	elif y > 2:
		k = (y - 1) // 2
		return k + get(x + k, y - 2 * k)
	elif x == 2 or y == 2:
		return 1
	return 0
print(get(a1, a2))


(n, m) = map(int, input().split())
c = 0
if n == 0 and m == 0 or (n == 1 and m == 1):
	print(0)
	exit(0)
for i in range(1000):
	if n <= 0 or m <= 0:
		break
	if m > n:
		m -= 2
		n += 1
		c += 1
	else:
		m += 1
		n -= 2
		c += 1
print(c)


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


alist = list(map(int, input().split()))
cnt = 0
while True:
	alist.sort()
	if alist[0] == 0 or (alist[0] == 1 and alist[1] == 1):
		break
	if alist[0] == 100:
		alist[0] -= 2
	else:
		alist[0] += 1
		alist[1] -= 2
	cnt += 1
print(cnt)


(f, s) = map(int, input().split())
mem = [[0 for i in range(500)] for i in range(500)]
if f == 1 and s == 1:
	print(0)
else:

	def check(a, b):
		if mem[a][b]:
			return mem[a][b]
		if a <= 0 or b <= 0:
			return 0
		else:
			mem[a][b] = 1 + max(check(a - 2, b + 1), check(a + 1, b - 2))
			return mem[a][b]
	print(check(f, s))


(a1, a2) = map(int, input().split())
tot = 0
while a1 >= 1 and a2 >= 1:
	if a1 >= a2:
		if a1 & 1:
			min = a1 // 2
			a1 = 1
		else:
			min = a1 // 2 - 1
			a1 = 2
		a2 += min
	else:
		if a2 & 1:
			min = a2 // 2
			a2 = 1
		else:
			min = a2 // 2 - 1
			a2 = 2
		a1 += min
	if min == 0:
		break
	tot += min
if a1 > 1 or a2 > 1:
	print(tot + 1)
else:
	print(tot)


dp = []
for i in range(321):
	l = [0 for j in range(321)]
	dp.append(l)
vis = []
for i in range(321):
	l = [0 for j in range(321)]
	vis.append(l)

def solve(n, m):
	if n > m:
		(n, m) = (m, n)
	if n <= 0:
		return 0
	if vis[n][m]:
		return dp[n][m]
	vis[n][m] = 1
	dp[n][m] = max(solve(n - 2, m + 1), solve(n + 1, m - 2)) + 1
	return dp[n][m]
(n, m) = map(int, input().split())
if n == 1 and m == 1:
	print(0)
else:
	print(solve(n, m))


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


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


(a, b) = (int(i) for i in input().split())
t = 0
if a > b:
	(a, b) = (b, a)
if b < 2:
	print(0)
else:
	while b > 2:
		x = (b - 1) // 2
		t += x
		a += x
		b -= 2 * x
		(a, b) = (b, a)
	print(t + 1)


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


def solve(a, b):
	if a == 1 and b == 1:
		return 0
	charg = 'a' if min(a, b) == a else 'b'
	m = 0
	while a > 0 and b > 0:
		m += 1
		if a <= 2 and charg != 'a':
			charg = 'a'
		elif b <= 2 and charg != 'b':
			charg = 'b'
		if charg == 'a':
			a += 1
			b -= 2
		else:
			b += 1
			a -= 2
	return m
xy = list(map(int, input().split()))
n = xy[0]
v = xy[1]
print(solve(n, v))


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


def main():
	(a1, a2) = map(int, input().split())
	chargers2max_play_time = {}
	print(get_max_play_time(a1, a2, chargers2max_play_time))

def get_max_play_time(a1, a2, chargers2max_play_time):
	if a1 < a2:
		return get_max_play_time(a2, a1, chargers2max_play_time)
	elif str(a1) + ' ' + str(a2) in chargers2max_play_time:
		return chargers2max_play_time[str(a1) + ' ' + str(a2)]
	elif a1 == 0 or a2 == 0:
		return 0
	else:
		if a2 > 1:
			max_lvl_left = get_max_play_time(a1 + 1, a2 - 2, chargers2max_play_time) + 1
		else:
			max_lvl_left = 0
		if a1 > 1:
			max_lvl_right = get_max_play_time(a1 - 2, a2 + 1, chargers2max_play_time) + 1
		else:
			max_lvl_right = 0
		max_lvl = max(max_lvl_left, max_lvl_right)
		key = str(a1) + ' ' + str(a2)
		chargers2max_play_time[key] = max_lvl
		return max_lvl
main()


l = input()
l = l.split()
n = int(l[0])
m = int(l[1])
s = 0
if n == 1 and m == 1:
	print(0)
else:
	while min(n, m) > 0:
		if n >= m:
			n -= 2
			m += 1
		else:
			n += 1
			m -= 2
		s += 1
	print(s)


a = list(map(int, input().split()))
output = 0
while 1:
	a = sorted(a)
	if a[1] < 3:
		break
	time = (a[1] - 1) // 2
	a[0] += time
	a[1] -= time * 2
	output += time
print(output if a[0] < 2 and a[1] < 2 else output + 1)


(a1, a2) = [int(x) for x in input().split()]
count = 0
while a1 != 0 and a2 != 0 and (a1 != 1 or a2 != 1):
	if a1 < a2:
		a1 += 1
		a2 -= 2
	else:
		a1 -= 2
		a2 += 1
	count += 1
print(count)


a = [int(i) for i in input().split()]
c = 0
a.append(a.index(min(a[0], a[1])))
while True:
	if a[0] * a[1] < 2:
		break
	if a[0] < 3 and a[1] > 2:
		a[2] = 0
	elif a[1] < 3 and a[0] > 2:
		a[2] = 1
	a[a[2]] += 1
	a[abs(a[2] - 1)] -= 2
	c += 1
print(c)


n = [int(num) for num in input().split()]
count = 0
while n[0] > 0 and n[1] > 0 and (n[0] + n[1] > 2):
	if n[1] > 2 and n[0] >= n[1]:
		n[1] = n[1] + 1
		n[0] = n[0] - 2
	elif n[0] > 2 and n[1] > n[0]:
		n[0] = n[0] + 1
		n[1] = n[1] - 2
	elif n[0] > 2 and n[1] <= 2:
		n[0] = n[0] - 2
		n[1] = n[1] + 1
	elif n[0] <= 2 and n[1] > 2:
		n[0] = n[0] + 1
		n[1] = n[1] - 2
	else:
		n[0] = 0
		n[1] = 0
	count = count + 1
print(count)


(n, m) = list(map(int, input().split()))
if abs(n - m) % 3 == 0 and n * m != 1:
	print(n + m - 3)
else:
	print(n + m - 2)


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


num = input()
a = []

def get_the_data(count, num, arr):
	for i in range(0, len(num)):
		if num[i] == ' ':
			arr.append(int(num[count:i]))
			count = i + 1
		elif i == len(num) - 1:
			arr.append(int(num[count:len(num)]))
	return arr
arr = get_the_data(0, num, a)
arr.sort()
if arr[0] < 2 and arr[1] < 2:
	print(0)
else:
	time = 0
	first = True
	while arr[0] > 0 and arr[1] > 0:
		if arr[0] == 1 or arr[0] == 2:
			first = True
		elif arr[1] == 1 or arr[1] == 2:
			first = False
		if first == True:
			arr[0] += 1
			arr[1] -= 2
		else:
			arr[1] += 1
			arr[0] -= 2
		time += 1
	print(time)


d = [int(x) for x in input().split(' ')]
c = 0
while d[0] > 0 and d[1] > 0:
	if d[0] <= d[1]:
		d[0] += 1
		d[1] -= 2
	else:
		d[0] -= 2
		d[1] += 1
	if d[0] >= 0 and d[1] >= 0:
		c += 1
print(c)


def game_time(a1, a2):
	if a1 > a2:
		(a1, a2) = (a2, a1)
	if a1 == 0 or a2 == 1:
		return 0
	return 1 + game_time(a1 + 1, a2 - 2)
print(game_time(*map(int, input().split())))


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


a = input().split()
a[0] = int(a[0])
a[1] = int(a[1])
if a[0] < a[1]:
	p = 0
else:
	p = 1
n = int(0)
if a[0] == 1 and a[1] == 1:
	n = 0
else:
	while a[0] > 0 and a[1] > 0:
		if p:
			a[1] += 1
			a[0] -= 2
		else:
			a[0] += 1
			a[1] -= 2
		if a[0] < a[1]:
			p = 0
		else:
			p = 1
		n += 1
print(n)


(x, y) = map(int, input().split())
ans = 0
if max(x, y) <= 1:
	print(0)
	exit()
while max(x, y) > 2:
	a = max(x, y)
	b = min(x, y)
	ans += (a - 1) // 2
	b += (a - 1) // 2
	a -= 2 * ((a - 1) // 2)
	x = a
	y = b
print(ans + 1)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

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

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_right(a, x)
	if i != len(a):
		return i
	else:
		return len(a)

def cal(a, b, ans, d):
	if (a < 1 or b < 1) or (a < 2 and b < 2):
		return ans
	if d.get((a, b), -1) != -1:
		return d[a, b]
	d[a, b] = max(cal(a + 1, b - 2, ans + 1, d), cal(a - 2, b + 1, ans + 1, d))
	return d[a, b]

def main():
	try:
		(a, b) = In()
		ans = 0
		d = {}
		t = cal(a, b, 0, d)
		print(t)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(1):
	main()


entrada = input()
entrada = entrada.split(' ')
uno = int(entrada[0])
dos = int(entrada[1])
if dos == 1 and uno == 1:
	print(0)
elif (dos - uno) % 3 == 0:
	print(uno + dos - 3)
else:
	print(uno + dos - 2)


'__author__' == 'deepak Singh Mehta(learning brute force)) '
(n, m) = map(int, input().split())
cnt = 0
if n == 1 and m == 1:
	print(0)
elif n < 3 and m < 3:
	print(1)
else:
	while n != 0 and m != 0:
		if n > m:
			n -= 2
			m += 1
		else:
			m -= 2
			n += 1
		cnt += 1
	print(cnt)


__author__ = 'artyom'

def main():
	(a, b) = read(3)
	return max(0, a + b - 3) if (a - b) % 3 == 0 else a + b - 2

def read(mode=1, size=None):
	if mode == 0:
		return input().strip()
	if mode == 1:
		return int(input().strip())
	if mode == 2:
		return input().strip().split()
	if mode == 3:
		return list(map(int, input().strip().split()))
	a = []
	for _ in range(size):
		a.append(read(3))
	return a

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


def main():
	(a1, a2) = (int(x) for x in input().split())
	print(solver(a1, a2))

def solver(x, y):
	if x <= 1 and y <= 1:
		return 0
	else:
		count = 1
		while x > 2 or y > 2:
			while x > 2:
				x -= 2
				y += 1
				count += 1
			while y > 2:
				y -= 2
				x += 1
				count += 1
		return count
main()


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


def func(a):
	if a[0] == 1 == a[1] or a[0] <= 0 or a[1] <= 0:
		return 0
	if a[0] < a[1]:
		a[0] += 1
		a[1] -= 2
		return 1 + func(a)
	else:
		a[1] += 1
		a[0] -= 2
		return 1 + func(a)
a = [int(i) for i in input().split()]
print(func(a))


k = list(map(int, input().split()))
i = 0
while min(k) and max(k) >= 2:
	(k[0], k[1]) = (max(k), min(k))
	k[0] -= 2
	k[1] += 1
	i += 1
print(i)


import sys

def getSrcData():
	f = sys.stdin
	buf = f.read()
	return [int(x) for x in buf.split(' ')]

def analyze(srcData):
	result = 0
	buf = list(srcData)
	buf.reverse() if buf[0] > buf[1] else None
	if buf[0] < 1:
		return 0
	result = (buf[1] - buf[0] + 1) // 3
	if result > 0:
		buf[0] += result
		buf[1] -= result * 2
	buf.reverse() if buf[0] > buf[1] else None
	if buf[0] > 2:
		result += (buf[0] - 2) * 2
		buf[1] -= buf[0] - 2
		buf[0] = 2
	result += 3 if buf[0] + buf[1] == 5 else 1
	result -= 1 if buf[0] + buf[1] == 2 else 0
	return result

def saveResult(resultScore):
	f = sys.stdout
	f.write(str(resultScore) + '\n')
	f.flush()

def run():
	srcData = getSrcData()
	result = analyze(srcData)
	saveResult(result)
run()


data = [int(information) for information in input().split(' ')]
j1 = data[0]
j2 = data[1]
minutes = 0
if j1 != 1 or j2 != 1:
	while j1 > 0 and j2 > 0:
		if j1 > j2:
			minutes += 1
			j2 += 1
			j1 -= 2
		else:
			minutes += 1
			j1 += 1
			j2 -= 2
print(minutes)


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


import sys
(a1, a2) = map(int, input().split())
t = 0
while 1:
	if a1 == 1 and a2 == 1:
		print(0)
		exit()
	if a1 <= 0 or a2 <= 0:
		break
	a = min(a1, a2)
	b = max(a1, a2)
	a += 1
	b -= 2
	a1 = a
	a2 = b
	t += 1
print(t)


a = [int(x) for x in input().split(' ')]
minutes = 0
while a[0] > 0 and a[1] > 0:
	if a[0] > a[1]:
		a[1] += 1
		a[0] -= 2
	else:
		a[0] += 1
		a[1] -= 2
	minutes += 1
if a[0] < 0 or a[1] < 0:
	print(minutes - 1)
else:
	print(minutes)


def solve(a, b):
	if a == 0 or b == 0:
		return 0
	elif a == 1 and b == 1:
		return 0
	elif a == 2 and b == 1:
		return 1
	elif a == 1 and b == 2:
		return 1
	else:
		if a == 2:
			return solve(a + 1, b - 2) + 1
		if b == 2:
			return solve(a - 2, b + 1) + 1
		if a > 2:
			return solve(a - 2, b + 1) + 1
		if b > 2:
			return solve(a + 1, b - 2) + 1
inp = input()
inp = inp.split()
print(solve(int(inp[0]), int(inp[1])))


import sys
import collections
import math
import functools
import itertools
import bisect
import operator
import heapq
import random
true = True
false = False
null = None
tcid = 0
tcmax = 99999999

def compute(val, func):
	return func(val)

def seq(lo, hi, step=1):
	return range(lo, hi + 1, step)

def sround(val, nd):
	return f'{val:.{nd}f}'

def ceil(a, b):
	ans = a // b
	if a % b != 0:
		ans += 1
	return ans

def perr(*args, **kwargs):
	print(*args, file=sys.stderr, **kwargs)

def line():
	ln = sys.stdin.readline().strip()
	if ln == '':
		sys.exit()
	return ln

def lines(n):
	return [line() for i in range(n)]

def split(ln=None):
	return (ln or line()).split()

def num(str=None):
	str = str or line()
	return float(str) if '.' in str else int(str)

def nums(o=None):
	if o is not None:
		if isinstance(o, int):
			o = lines(o)
		elif isinstance(o, str):
			o = split(o)
	return list(map(num, o or split()))

def mainloop(tcid=1):
	(a, b) = nums()

	@functools.lru_cache(None)
	def rec(aa, bb):
		if aa < 1 or bb < 1:
			return 0
		if aa < 2 and bb < 2:
			return 0
		ans = 1 + max(rec(aa + 1, bb - 2), rec(aa - 2, bb + 1))
		return ans
	print(rec(a, b))
while tcid < tcmax:
	tcid += 1
	mainloop(tcid)


import math
import itertools
import collections

def getdict(n):
	d = {}
	if type(n) is list:
		for i in n:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
	else:
		for i in range(n):
			t = ii()
			if t in d:
				d[t] += 1
			else:
				d[t] = 1
	return d

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)
a = li()
suma = sum(a)
if a[0] == a[1] or abs(a[0] - a[1]) % 3 == 0:
	print(max(0, suma - 3))
else:
	print(suma - 2)


a = [int(x) for x in input().split()]
high = max(a[0], a[1])
low = min(a[0], a[1])
diff = high - low
mod = (high - low) % 3
if mod == 0:
	print(max(high + low - 3, 0))
else:
	print(max(high + low - 2, 0))


def inp():
	return map(int, input().split())
(a1, a2) = inp()
count = 0
while a1 and a2:
	if a1 == a2 == 1:
		break
	if a1 <= a2:
		a1 += 1
		a2 -= 2
	else:
		a2 += 1
		a1 -= 2
	count += 1
print(count)


s = input().split()
a = int(s[0])
b = int(s[1])
count = 1
if a < 2 and b < 2:
	print(0)
else:
	while True:
		if a <= b:
			a += 1
			b -= 2
		elif b < a:
			a -= 2
			b += 1
		if a <= 0 or b <= 0:
			print(count)
			break
		count += 1


def solve(a, b, length, memo):
	if memo[a][b] is not None:
		return memo[a][b]
	if a == 0 or b == 0:
		memo[a][b] = length
		return memo[a][b]
	memo[a][b] = max(solve(a + 1, max(b - 2, 0), length + 1, memo), solve(max(a - 2, 0), b + 1, length + 1, memo))
	return memo[a][b]
(a, b) = map(int, input().split())
m = [[None] * 200 for x in range(200)]
m[1][1] = 0
print(solve(a, b, 0, m))


import sys
import os
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')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	lst = []
	for i in range(n):
		temp = [default] * m
		lst.append(temp)
	return lst

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

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


import math
import collections
import bisect
import heapq
import time
import random
import itertools
import sys
(a, b) = map(int, input().split())
ans = 0
while a > 0 and b > 0 and (a + b > 2):
	if a < b:
		a += 1
		b -= 2
	else:
		b += 1
		a -= 2
	ans += 1
print(ans)


ab = input().split()
a = int(ab[0])
b = int(ab[1])
m = 0
while a > 0 and b > 0:
	if a > 2:
		a -= 2
		b += 1
	elif a == 1 and b == 1:
		break
	else:
		a += 1
		b -= 2
	m += 1
print(m)


def func(a, b):
	if a == 0 or b == 0:
		return 0
	if a + b == 2:
		return 0
	(a, b) = (max(a, b), min(a, b))
	ans = 0
	for i in range(9999):
		(a, b) = (max(a, b), min(a, b))
		a -= 2
		b += 1
		ans += 1
		if a < 1 or b < 1:
			return ans
a = list(map(int, input().split()))
print(func(a[0], a[1]))


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
	ans += 1
print(ans)


(n, t) = map(int, input().split())
res = 0
while n > 2 or t > 2:
	if n > t:
		tmp = int(n / 2)
		if tmp * 2 == n:
			tmp -= 1
		res += tmp
		t += tmp
		n -= tmp * 2
	else:
		tmp = int(t / 2)
		if tmp * 2 == t:
			tmp -= 1
		res += tmp
		n += tmp
		t -= tmp * 2
if n == 2 or t == 2:
	res += 1
print(res)


(a1, a2) = map(int, input().split())
if a1 == 1 and a2 == 1:
	x = 3
	print(0)
elif a1 == 1 and a2 == 2 or (a2 == 1 and a1 == 2) or (a1 == 2 and a2 == 2):
	x = 3
	print(1)
elif a1 < a2:
	a1 += 1
	a2 -= 2
	x = 1
else:
	a2 += 1
	a1 -= 2
	x = 2
h = 1
while True:
	if a1 == 2 and x == 2:
		x = 1
	elif a2 == 2 and x == 1:
		x = 2
	elif a1 == 1 and x == 2:
		x = 1
	elif a2 == 1 and x == 1:
		x = 2
	if x == 1:
		a1 += 1
		a2 -= 2
	else:
		a2 += 1
		a1 -= 2
	h += 1
	if a1 <= 0 or a2 <= 0 or x == 3:
		break
if x != 3:
	print(h)


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


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


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


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


def charge_discharge(x, y):
	return (x + 1, y - 2)
(p1, p2) = map(int, input().split())
minutes = 0
while p1 > 0 and p2 > 0 and (not (p1 == 1 and p2 == 1)):
	minutes += 1
	if p1 == 1:
		(p1, p2) = charge_discharge(p1, p2)
	elif p2 == 1:
		(p2, p1) = charge_discharge(p2, p1)
	elif p1 < p2:
		(p1, p2) = charge_discharge(p1, p2)
	else:
		(p2, p1) = charge_discharge(p2, p1)
print(minutes)