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

Difficulty: introductory

Starter code:

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 = list(map(int, input().split()))

if N <= M/2:
    ans = N + (M - 2*N)//4
else:
    ans = M//2
print(ans)


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 n<m:
    print(n+(m-2*n)//4)
else:
    print(m//2)

N,M = map(int,input().split())
if N >= M // 2:
    ans = M//2
else:
    ans = N + (M-2*N)//4
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)

#!/usr/bin/env python

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)

# C - Scc Puzzle
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 = map(int, input().split())
if 2*N < M:
    extra = (M - 2*N) // 4
    ans = N + extra
else:
    ans = M // 2
print(ans)

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 = map(int, 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 = M - 2*N
    count_SCC = N + M//4
elif M < 2*N : #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())
if 2*n>=m:
  print(m//2)
else:
  ans=n
  ans+=(m-2*n)//4
  print(ans)

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

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

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


S, C = list(map(int, input().split()))
ans = 0

# 初期のSで可能な限りSCCを作る
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)

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


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)

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

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

c = m - n * 2
if c > 0:
    print(n + c // 4)
else:
    print(m // 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()))

# N + x : M - 2x = 1 : 2
# M - 2x = 2N + 2x
# x = (M - 2N) / 4

if N * 2 >= M:
  print((int(M / 2)))
else:
  x = (M - 2 * N) / 4
  N += int(x)
  M -= 2 * int(x)
  print(N)
  
  


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


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


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

import sys
import math

N, M = list(map(int, input().split()))

count = min(M//2, N)
M -= count*2
print(count + M//4)

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

s, c = map(int,input().split())

cnt = 0
if 2*s <= c:
    cnt += s
    c -= 2*s
else:
    cnt += c // 2
    c = 0

cnt += c//4
print(cnt)

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


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


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

if m - 2*n <0:
    print(m//2)
else:
    ans = n
    m -= 2*n
    ans += m//4
    print(ans)

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

if(2*n>=m):
	print((m//2))
else:
	remaining = m- n*2
	ans = remaining//4 + n
	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().split())

ans = 0
if n*2 <= m:
  ans += n
  m -= n*2
else:
  ans += m//2
  print(ans)
  return
  
if 4 <= m: ans += m//4
print(ans)

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

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

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

if 2*n<m:
    ans=n+(m-(2*n))//4
else:
    ans=m//2

print(ans)

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)

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

ans = 0
if n < m:
    if 2*n <= m:
        m = m -2*n
        ans += n
    
    ans += m//4
else:
    ans += m//2

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

if c>=s*2:
  ans=s+(c-s*2)//4
  
else:
  ans=c//2
  
print(ans)

n, m = list(map(int, input().split()))
res = 0
if n > m // 2:
    res = m // 2
    print(res)
else:
    res = n
    n -= res
    m -= res * 2
    # ここでnは0
    res += m // 4
    print(res)


#n = int(input())
n, m = list(map(int, input().split()))
#l = list(map(int,input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

if n >= m//2:
    ans = m//2
else:
    m -= n*2
    ans = n + m//4

print(ans)


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

if m < n * 2:
    ans = m//2
else:
    ans = n + (m-n*2)//4

print(ans)

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


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

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

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


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

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

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

if 2*n <= m: print(n + (m-2*n)//4)
else: print(m//2)

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 2*N >= M:
  ans = M//2
else:
  ans += N
  C = M-2*N
  ans += C//4
  
print(ans)

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


# -*- coding: utf-8 -*-
"""
Created on Wed Sep 30 00:56:12 2020

@author: liang
"""

N, M = map(int, input().split())

if N*2 >= M:
    print(M//2)
else:
    print( N + (M-2*N)//4)

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

if n * 2 < m:
  print(n + (m - n * 2) // 4)
else:
  print(m // 2)

#
# abc055 c
#

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():
    # unittest.main()
    resolve()

__starting_point()

#!/usr/bin/env python

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

ans = 0 
cc = m//2
if n >= cc: 
    ans = cc
else:
    ans = (n+cc)//2
print(ans)


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


def __starting_point():
    main()

__starting_point()

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 = map(int,input().split())
if N <= M // 2:
    print(N + (M - 2 * N) // 4)
else:
    print(M // 2)

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

M-=2*N
ans+=M//4
print(ans)

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

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

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(s,c)
print(m)


N,M=map(int,input().split())
#S=N,C=M
print(min(((2*N)+M)//4,M//2))

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

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


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

if N < M:
    print(N + (M - 2 * N) // 4)
else:
    print(M // 2)

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)

N, M = map(int, input().split())

ans = 0
if(M//2 >= N):
    ans += N
    M = M - N*2    
    ans += M//4
    
else:
    ans += M//2

print(ans)