Snuke loves puzzles.
Today, he is working on a puzzle using S- and c-shaped pieces.
In this puzzle, you can combine two c-shaped pieces into one S-shaped piece, as shown in the figure below:
Snuke decided to create as many Scc groups as possible by putting together one S-shaped piece and two c-shaped pieces.
Find the maximum number of Scc groups that can be created when Snuke has N S-shaped pieces and M c-shaped pieces.

-----Constraints-----
 - 1 ≤ N,M ≤ 10^{12}

-----Input-----
The input is given from Standard Input in the following format:
N M

-----Output-----
Print the answer.

-----Sample Input-----
1 6

-----Sample Output-----
2

Two Scc groups can be created as follows:
 - Combine two c-shaped pieces into one S-shaped piece
 - Create two Scc groups, each from one S-shaped piece and two c-shaped pieces

Source: atcoder | Difficulty: EASY


Solutions:
(n, m) = [int(x) for x in input().split()]
ans = min(n, m // 2)
ans += (m - ans * 2) // 4
print(ans)


(N, M) = map(int, input().split())
ans = 0
if 2 * N <= M:
	ans += N
	M -= 2 * N
else:
	ans += M // 2
	M -= M // 2 * 2
ans += M // 4
print(ans)


def main():
	(n, m) = map(int, input().split())
	if m - 2 * n >= 0:
		m -= 2 * n
		ans = n
		n = 0
		if (m - 2 * n) % 4 == 0:
			tmp = (m - 2 * n) // 4
		else:
			tmp = (m - 2 * n) // 4 + 1
		ans += (m - 2 * tmp) // 2
	else:
		ans = m // 2
	print(ans)

def __starting_point():
	main()
__starting_point()


(s, c) = map(int, input().split())
c = c // 2
if s == c:
	print(s)
elif s > c:
	print(c)
elif s < c:
	t = c - s
	print(s + t // 2)


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


(n, m) = map(int, input().split())
ans = 0
if m - n * 2 > 0:
	ans += n
	tmp = m - n * 2
	ans += tmp // 4
else:
	ans += m // 2
print(ans)


(n, m) = map(int, input().split())
if 0 <= 2 * n - m:
	num = m // 2
else:
	num = n
	num += (m - 2 * n) // 4
print(num)


(n, m) = list(map(int, input().split()))
cc = m // 2
ans = min(n, cc)
res = cc - min(n, cc)
if res > 0:
	ans += res // 2
print(ans)


import math
(N, M) = (int(T) for T in input().split())
if M - 2 * N > 0:
	Convert = int(math.floor((M - 2 * N) / 4))
	N += Convert
	M -= 2 * Convert
	print(N)
else:
	print(M // 2)


(N, M) = map(int, input().split())
print(M // 2 if 2 * N > M else N + (M - 2 * N) // 4)


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


def main():
	(n, m) = map(int, input().split())
	if m - n * 2 >= 0:
		print(n + (m - n * 2) // 4)
	else:
		print(m // 2)

def __starting_point():
	main()
__starting_point()


(N, M) = (int(T) for T in input().split())
if 2 * N < M:
	print(N + (M - 2 * N) // 4)
else:
	print(M // 2)


(N, M) = map(int, input().split())
M //= 2
print(min(M, (N + M) // 2))


(n, m) = list(map(int, input().split()))
if m < 2:
	print(0)
	return
if n > m // 2:
	print(m // 2)
	return
c = n % (m // 2)
d = m - 2 * c
c += d // 4
print(c)


(s, c) = map(int, input().split())
if 2 * s <= c:
	ans = s
	c = c - 2 * s
else:
	ans = c // 2
	c = 0
if c >= 4:
	ans += c // 4
print(ans)


(n, m) = [int(i) for i in input().split()]
if 2 * n >= m:
	print(m // 2)
else:
	print(n + (m - 2 * n) // 4)


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


(N, M) = list(map(int, input().split()))
total = 2 * N + M
ans = total // 4
if ans * 2 > M:
	ans = M // 2
print(ans)


import sys
(N, M) = map(int, input().split())
if not (1 <= N <= 10 ** 12 and 1 <= M <= 10 ** 12):
	return
count_SCC = 0
if M > 2 * N:
	M = M - 2 * N
	count_SCC = N + M // 4
elif M < 2 * N:
	count_SCC = M // 2
print(count_SCC)


(n, m) = [int(x) for x in input().split()]
res = 0
if 2 * n >= m:
	res = m // 2
else:
	res = n
	m -= 2 * n
	res += m // 4
print(res)


(N, M) = [int(a) for a in input().split()]
a1 = min(N, M // 2)
a2 = 0
if M // 2 > N:
	a2 = (M - N * 2) // 4
a3 = a1 + a2
print(a3)


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


(n, m) = map(int, input().split())
ans = min(n, m // 2)
m -= ans * 2
ans += max(0, m // 4)
print(ans)


(S, C) = list(map(int, input().split()))
ans = 0
if S * 2 <= C:
	C = C - S * 2
	ans += S
	ans += C // 4
else:
	ans += C // 2
print(int(ans))


import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007

def main():
	(N, M) = list(map(int, readline().split()))
	if N >= M // 2:
		ans = M // 2
	else:
		ans = N
		L = M - 2 * N
		ans += L // 4
	print(ans)
	return

def __starting_point():
	main()
__starting_point()


(s, c) = map(int, input().split())
if 2 * s <= c:
	print((s + c // 2) // 2)
else:
	print(c // 2)


import sys
input = lambda : sys.stdin.readline()
(n, m) = list(map(int, input().split()))
if m - 2 * n >= 0:
	print(n + (m - 2 * n) // 4)
else:
	print(m // 2)


(s, c) = map(int, input().split())
p = s * 2
if p <= c:
	print(s + (c - p) // 4)
else:
	print(c // 2)


(a, b) = map(int, input().split())
if a * 2 <= b:
	c = (b - a * 2) // 4
	print(a + c)
if a * 2 > b:
	print(b // 2)


(N, M) = list(map(int, input().split()))
if N * 2 >= M:
	print(int(M / 2))
else:
	x = (M - 2 * N) / 4
	N += int(x)
	M -= 2 * int(x)
	print(N)


import sys
(n, m) = list(map(int, input().split()))
if m < 2:
	print(0)
	return
if 1 < m < n or 2 * n > m >= n:
	print(m // 2)
	return
m -= 2 * n
print(n + m // 4)


import sys
import math
(N, M) = list(map(int, input().split()))
count = min(M // 2, N)
M -= count * 2
print(count + M // 4)


(S, C) = map(int, input().split())
ans = min(S, C // 2)
S -= ans
C -= ans * 2
if C >= 4:
	ans += C // 4
print(ans)


(n, m) = map(int, input().split())
ans = 0
if m >= 2 and n > 0:
	ans += min(n, m // 2)
	m -= 2 * ans
if m > 0:
	ans += m // 4
print(ans)


(N, M) = map(int, input().split())
if N >= M // 2:
	print(M // 2)
else:
	m = M - N * 2
	s = m // 4
	print(N + s)


(N, M) = map(int, input().rstrip().split(' '))
k = N * 2 + M
print(min(k // 4, M // 2))


(N, M) = list(map(int, input().split()))
A = 0
if 2 * N <= M:
	A += N
	M -= 2 * N
	print(A + M // 4)
else:
	print(M // 2)


(s, c) = list(map(int, input().split()))
if 2 * s == c:
	ans = s
elif 2 * s > c:
	ans = c // 2
else:
	ans = s
	tar = c - 2 * s
	ans += tar // 4
print(int(ans))


(N, M) = map(int, input().split())
if N >= 2 * M:
	print(M // 2)
	return

def f(x):
	return max(min(N + x, (M - 2 * x) // 2), 0)
delta = [-3, -2, -1, 0, 1, 2, 3]
x = (M - 2 * N) // 4
ans = 0
for i in range(7):
	x_ = max(0, x + delta[i])
	ans = max(ans, f(x_))
print(ans)


(S, C) = [int(n) for n in input().split(' ')]
if 2 * S >= C:
	print(min([S, int(C / 2)]))
else:
	print(S + int((C - 2 * S) / 4))


(N, M) = map(int, input().split())
n = N
m = M // 2
ans = 0
if n >= m:
	ans += m
else:
	ans += n
	m -= n
	ans += m // 2
print(ans)


(s, c) = map(int, input().split())
print((s + (c - s * 2) // 4, c // 2)[s * 2 >= c])


(N, M) = map(int, input().split())
print(min(N, M // 2) + max(M - N * 2, 0) // 4)


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


(N, M) = list(map(int, input().split()))
if 2 * N >= M:
	print(M // 2)
	return
print(N + (M - 2 * N) // 4)


import sys
from io import StringIO
import unittest

class TestClass(unittest.TestCase):

	def assertIO(self, input, output):
		(stdout, stdin) = (sys.stdout, sys.stdin)
		(sys.stdout, sys.stdin) = (StringIO(), StringIO(input))
		resolve()
		sys.stdout.seek(0)
		out = sys.stdout.read()[:-1]
		(sys.stdout, sys.stdin) = (stdout, stdin)
		self.assertEqual(out, output)

	def test_入力例_1(self):
		input = '1 6'
		output = '2'
		self.assertIO(input, output)

	def test_入力例_2(self):
		input = '12345 678901'
		output = '175897'
		self.assertIO(input, output)

def resolve():
	(N, M) = list(map(int, input().split()))
	if M >= 2 * N:
		print(N + (M - 2 * N) // 4)
	else:
		print(M // 2)

def __starting_point():
	resolve()
__starting_point()


(n, m) = list(map(int, input().split()))
ans = 0
cc = m // 2
if n >= cc:
	ans = cc
else:
	ans = (n + cc) // 2
print(ans)


(n, m) = map(int, input().split())
if n * 2 >= m:
	print(m // 2)
	return
res = n
m -= 2 * n
res += m // 4
print(res)


(N, M) = list(map(int, input().split()))
if N * 2 > M:
	print(M // 2)
elif N * 2 == M:
	print(N)
else:
	count = N
	M -= 2 * N
	count += M // 4
	print(count)


(s, c) = list(map(int, input().split()))
i = min(s, c // 2)
m = i
s -= i
c -= i * 2
if s == 0:
	m += c // 4
print(m)


import sys
(N, M) = list(map(int, input().split()))
Mh = M // 2
if N > Mh:
	print(Mh)
	return
else:
	rem = M - 2 * N
	print(rem // 4 + N)


(s, c) = map(int, input().split())
ans = 0
ans += min(s, c // 2)
res = c - min(s, c // 2) * 2
ans += res // 4
print(ans)