Problem:
 Score : 300 points    Problem Statement 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 1 6      Sample Output 1 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        Sample Input 2 12345 678901      Sample Output 2 175897

Solution (Python):
N, M = map(int, input().split())

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

print(ans)

Solution (Python):
s,c=map(int,input().split())
print(min(c//2,s+(c-2*s)//4))

Solution (Python):
x,y=list(map(int, input().split()))
ans=0

if x*2>=y:
	ans=ans+(y//2)
	x=x-(y//2)
	y=y%2
else:
	ans=ans+x
	y=y-(x*2)
	x=0

print(ans+(y//4))

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

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

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

Solution (Python):
n,m=map(int,input().split())
p1=n
p2=m//2
if p1>p2:
    print(p2)
else:
    delta=p2-p1
    print(delta//2+p1)

Solution (Python):
N,M=map(int,input().split())

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

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

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

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

Solution (Python):
sc, cc = map(int, input().split())

if sc >= cc//2:
  print(cc//2)
else:
  c = (cc-2*sc)//4
  print(sc+c)

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

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

Solution (Python):
n, m = (int(x) for x in input().split())
a = 0
if n < m // 2:
    a += n
    m -= n * 2
    a += m // 4
else:
    a += m // 2
print(a)

Solution (Python):
N, M = map(int, input().split())
m = min(N, M//2)
N = N-m
M = M - m * 2
if N == 0:
    print(m + M//4)
else:
    print(m)

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

Solution (Python):
n, m = map(int, input().split())
res = min(n, m//2)
n -= res
m -= (res * 2)

res += m // 4
print(res)

Solution (Python):
s,m = map(int,input().split())
cnt = 0
if s >= m//2:
    cnt = m//2
else:
    m = m-2*s
    cnt = s+m//4
print(cnt)

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


print(ans)

Solution (Python):
n, m = map(int, input().split())

if 2*n >= m:
    print(m//2)
    exit(0)


c = m - (2*n)
s = c // 4

print(n+s)

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

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

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

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

Solution (Python):
def main():
    s, c = [int(x) for x in input().split()]

    total = s
    s_req = s * 2

    if c <= s_req:
        print(c // 2)
        return

    c -= s_req
    total += c // 4

    print(total)



if __name__ == "__main__":
    main()

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

Solution (Python):
import sys
n, m = [int(i) for i in sys.stdin.readline().split()]
cnt = 0
if m >= 2 * n:
    cnt += n
    m -= n * 2
else:
    cnt += m // 2
    m = 0
print(cnt + m // 4)

Solution (Python):
N, M = map(int, input().split())
if 2 * N > M:
  print(M // 2)
else:
  C = M // 2
  n = (C - N) // 2
  print(max(min(N+n-1, C-n+1), min(N+n, C-n), min(N+n+1, C-n-1)))

Solution (Python):

import sys
import string

class cin():
    def int():
        return int(sys.stdin.readline().rstrip())
    def string():
        return sys.stdin.readline().rstrip()
    def mapInt():
        return [int(x) for x in cin.string().split()]
    def stringList(n):
        return [input() for i in range(n)]
    def intListList(n):
        return [cin.mapInt() for i in range(n)]
    def intColsList(n):
        return [int(input()) for i in range(n)]
        
class Math():
    def gcd(a,b):
        if b == 0:
            return a
        return Math.gcd(b,a % b)
    def lcm(a,b):
        return (a * b) // Math.gcd(a,b)
    def roundUp(a,b):
        return -(-a // b)
    def toUpperMultiple(a,x):
        return Math.roundUp(a,x) * x
    def toLowerMultiple(a,x):
        return (a // x) * x
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3,d + 1,2):
            if n % i == 0:
                return False
        return True

MOD = int(1e09) + 7

def main():
    N,M = cin.mapInt()
    ans = min(N,M // 2)
    N -= ans 
    M -= ans * 2
    ans += M // 4
    print(ans)
    return

if __name__ == "__main__":
    main()

Solution (Python):
S,C = map(int, input().split())

if S*2 < C:
    

    
    scc_num=S
    C -= S*2

    
    scc_num += int(C/4)

else:
    
    scc_num=int(C/2)

print(scc_num)

Solution (Python):

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)

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


if __name__ == '__main__':
    main()

Solution (Python):
N ,M = map(int,input().split())

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

Solution (Python):
def examC():
    N, M = LI()
    if N-M//2>=0:
        ans = M//2
    else:
        ans = N + (M-N*2)//4
    print(ans)
    return

def examD():
    return

def examE():
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    examC()

"""

"""

Solution (Python):
n,m = map(int,input().split())

ans = 0

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


print(ans)

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

Solution (Python):
N, M = map(int, input().split())

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

Solution (Python):
s,c = list(map(int,input().split()))
if 2*s >= c:
    print(c//2)
else:
    suma = s
    c -= 2*s
    suma += c//4
    print(suma)

Solution (Python):
n, m = map(int, input().split())
ansmax = m//2
ans = (n*2+m)//4
if ans > ansmax:
    ans = ansmax
print(ans)

Solution (Python):
n, m = map(int, input().split())

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

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

Solution (Python):
N,M = map(int,input().split())

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

Solution (Python):
n,m = map(int,input().split())
x = n * 2 + m
y = x // 4
z = m // 2
ans = min(y,z)
print(ans)

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

Solution (Python):
S,C=map(int,input().split())

if 2*S>=C:
    print(C//2)
else:
    print(S+((C-2*S)//4))

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

Solution (Python):
N, M = map(int, input().split())

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

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

Solution (Python):

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


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

print(ans)

Solution (Python):
s,c=map(int,input().split())

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

Solution (Python):
N, M = map(int, input().split())

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

Solution (Python):
s, c = map(int, input().split())

cnt = 0
if c < s*2:
    cnt = c//2
    print(cnt)
else:
    cnt = s
    c -= 2*s
    cnt += c//4
    print(cnt)

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

Solution (Python):
'''
　 ∧_,,∧    究極奥義「WAがACになーれ！！」
　（`・ω・)つ━☆・*。
　⊂　　 ノ 　　　・゜+.
　 し’´Ｊ　　*・ 
'''
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
if 2*n<=m:
    print(n+(m-2*n)//4)
else:
    print(m//2)

Solution (Python):
n, m = map(int, input().split())

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

Solution (Python):
n,m=map(int,input().split())

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

Solution (Python):
n,m = [int(i) for i in input().split()]

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

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

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline


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


if __name__ == '__main__':
    main()

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    cnt = min(n, m // 2)
    n -= cnt
    m -= (cnt * 2)
    if m != 0:
        cnt += (m // 4)
    print(cnt)


if __name__ == '__main__':
    slove()

Solution (Python):
N, M = map(int, input().split())

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

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

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

Solution (Python):
s,c=map(int,input().split())

ans=0

ans+=min(s,c//2)
s-=ans
c-=ans*2


ans+=c//4
print(ans)

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

Solution (Python):
import sys
def input():
	return sys.stdin.readline().strip()

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

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

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

Solution (Python):
n, m = [int(x) for x in input().split(' ')]

ans = 0

if m == 1:
    ans = 0
elif n * 2 > m:
    ans = m // 2
elif n * 2 + 4 > m:
    ans = n
else:
    ans = (m - (n*2)) // 4 + n

print(ans)

Solution (Python):
N,M=map(int,input().split())

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

Solution (Python):
n,m=map(int, input().split())

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

Solution (Python):
def slove():
    import sys
    input = sys.stdin.readline
    n, m = list(map(int, input().rstrip('\n').split()))
    cnt = min(n, m // 2)
    n -= cnt
    m -= cnt * 2
    if m != 0:
        cnt += (m // 4)
    print(cnt)


if __name__ == '__main__':
    slove()

Solution (Python):
N,M = (int(x) for x in input().split())


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

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

Solution (Python):
from collections import Counter,defaultdict
import sys,heapq,bisect,math,itertools,string,queue
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

n,m = inpl()
if n*2 >= m:
    print(m//2)
else:
    m -= n*2
    print(n+m//4)

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

Solution (Python):
n, m = map(int, input().split())
cnt = min(n, m // 2)
m -= cnt * 2
n -= cnt
cnt += m // 4 if m != 0 else 0
print(cnt)

Solution (Python):
N,M = map(int,input().split())

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

Solution (Python):
N, M = map(int, input().split())

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

print(ans)

Solution (Python):
N, M = [int(_) for _ in input().split()]

tmp = min(N, M // 2)
cnt = tmp
M -= tmp * 2
if M > 0:
    cnt += M // 4
print(cnt)

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

print(ans)

Solution (Python):
n,m=map(int,input().split())
m=m//2
if n<m+1:
	n=(n+m)//2
	m=n
print(min(n,m))

Solution (Python):


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

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

Solution (Python):


import sys


tmp = input().split()
hoge = list(map(lambda a: int(a), tmp))
n=hoge[0]
m=hoge[1]

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

Solution (Python):
a, b = map(int, input().split())
c = min(a, b//2)
b -= c * 2
if b != 0:
    print(c + b // 4)
else:
    print(c)

Solution (Python):
N, M = map(int,input().split())

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

Solution (Python):
N,M = [int(zz) for zz in input().split()]

ans = 0
if 2*N <= M:
    ans += N
    M -= 2*N
else:
    ans += M//2
    M %= 2

ans += M//4
print(ans)

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

Solution (Python):
N, M = map(int, input().split())

if 2 * N == M:
    print(N)
elif 2 * N > M:
    print(M // 2)
elif 2 * N < M:
    count = N
    tmp = M - 2 * N
    count += tmp // 4
    print(count)

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

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

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

Solution (Python):
N, M = map(int,input().split())




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

    ans += r // 4  

    print(ans)

Solution (Python):
n, m = [int(i) for i in input().split()]

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

Solution (Python):

def main():
    n, m = map(int, input().rstrip().split())
    ans = min(n, m // 2)
    ans += (m - ans * 2) // 4
    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):

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


if __name__ == "__main__":
    main()

Solution (Python):
N,M = map(int,input().split())
if M%2 == 1:
    M -= 1
if M < N * 2:
    print(M//2)
else:
    ans = N + (M//2 - N)//2
    print(ans)

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

print(ans)

Solution (Python):
n,m = map(int,input().split())

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

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

Solution (Python):
N, M = map(int, input().split())

M -= N * 2

if M <= 0:
  print(N - (-M + 1) // 2)
else:
  print(N + M // 4)

Solution (Python):
from math import floor
s_num, c_num = tuple(int(i) for i in input().split(" "))
ans = 0
temp = s_num * 2
if c_num <= temp:
    ans += floor(c_num / 2)
else:
    ans += s_num
    ans += floor((c_num - temp) / 4)
print(ans)

Solution (Python):
N, M = map(int, input().split())
n_cc, rem = divmod(M, 2)
ans = min(N, n_cc)
n_cc -= ans
if n_cc > 0:
    ans += (n_cc * 2 + rem) // 4
print(ans)

Solution (Python):
N,M = map(int,input().split())

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

Solution (Python):

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

ans = 0
N 
2*N 

kosu = min(M//2,N)  

ans += kosu
M -= 2*kosu
N -= kosu


ans += M//4

print(ans)

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

Solution (Python):

"""
C - Scc Puzzle
https://atcoder.jp/contests/arc069/tasks/arc069_a

"""
import sys


def solve(s, c):
    ans = min(s, c//2)
    s -= ans
    c -= (ans * 2)
    s += (c // 2)
    c //= 2
    ans += min(s, c//2)
    return ans


def main(args):
    s, c = map(int, input().split())
    ans = solve(s, c)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

Solution (Python):
N, M = map(int, input().split())

count = 0

if 2 * N <= M:
    count += N
    M = M - 2 * N
    
    count += M // 4
    
else:
    count += M // 2

print(count)

Solution (Python):
N,M = map(int,input().split(" "))
s = min(N,M//2)
s += (M - s * 2) // 4
print(s)

Solution (Python):
N, M = map(int,input().split())

basic = min(N,M // 2)
c = M - basic * 2

basic += c // 4;
print(basic)

Solution (Python):
N, M = map(int, input().split())

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

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

Solution (Python):
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools
import copy
import collections
from operator import itemgetter

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

s,c= (int(i) for i in input().split())       









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

Solution (Python):
import sys
input = sys.stdin.readline

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

c = 0
if N * 2 <= M:
    c = N
    M = M - N * 2
elif N != 0:
    c = int(M / 2)
    M = M - c * 2
    
print(c + int(M / 4))

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

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

Solution (Python):
n,m = map(int,input().split())

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

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

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

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

Solution (Python):
from sys import exit, stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
r = M-2*N
if r <= 0:
    print(M//2)
else:
    print(N+r//4)

Solution (Python):
N, M = map(int, input().split())

ans = 0
if N*2 <= M:
    ans += N
    M -= N*2
    ans += M // 4
else:
    ans += M // 2

print(ans)

Solution (Python):


S,c = map(int, input().split())
scc = 0

if(c <= 2*S):
    print(c//2)
else:
    scc = S + (c-2*S)//4
    print(scc)

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

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

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

Solution (Python):
N, M = map(int, input().split())

ans = 0
if 2 * N <= M:
    ans += N
    M -= 2 * N
    ans += M // 4
else:
    ans += M // 2

print(ans)

Solution (Python):
N,M = map(int,input().split())

count = N if N*2<=M else M//2
M -= N*2
count += M//4 if M>0 else 0

print(count)

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

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

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

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

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

solve()

Solution (Python):
s, c = map(int, input().split())
count = s
a1 = int((c-2*s)/2)
a2 = int(a1/2)

s_add = int((int((c-2*s)/2))/2)
if 2 * s <= c: 
  print(s + s_add)
else:
  print(c // 2)

Solution (Python):
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n, m = nm()
if m >= 2 * n:
    c = m - 2 * n
    print(n + (c // 4))
else:
    print(m // 2)

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

Solution (Python):
N, M = map(int, input().split())

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

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

Solution (Python):
S,C=map(int,input().split(' '))
print(min(S,C//2)+(C-min(S,C//2)*2)//4)

Solution (Python):
N,M = map(int,input().split())
S_num = N
cc_num = M//2
if(S_num <= cc_num):
 ans = (S_num+cc_num)//2
else:
 ans = cc_num
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def POW(x, y):
    if y == 0:
        return 1
    elif y == 1:
        return x
    elif y % 2 == 0:
        return POW(x, y // 2) ** 2 % MOD
    else:
        return POW(x, y // 2) ** 2 * x % MOD
def mod_factorial(x, y): return x * POW(y, MOD - 2) % MOD
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()
from functools import reduce

def main():
    N, M = LI()
    if N >= M // 2:
        return M // 2
    rem = M - 2 * N
    ans = N + rem // 4
    return ans

print(main())

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

Solution (Python):







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

Solution (Python):
s,c=map(int,input().split())
a=min(s,c//2)
c-=s*2
a+=max(0,c//4)
print(a)

Solution (Python):
n,m=map(int,input().split())

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

Solution (Python):
N,M = map(int,input().split())

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

print(res)

Solution (Python):
def fun():
     print('ac')
     print('ac')
     print('ac')
     print('ac')
N,M=map(int,input().split())
if N*2>=M:
     print(M//2)
else:
     result=N+(M-2*N)//4
     print(result)

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

Solution (Python):
n, m = map(int, input().split())

k = min(m // 2, (n + m // 2) // 2)
print(k)

Solution (Python):


"""
Created on Sat Feb  9 10:45:37 2019

@author: shinjisu
"""



def getIntList(): return [int(x) for x in input().split()]


def db(x):
    global debug
    if debug:
        print(x)


def solve():
    if N >= M//2:
        return M//2
    return N + (M-N*2)//4


debug = False
N, M = getIntList()
db((N, M))
print(solve())

Solution (Python):
N,M=map(int,input().split())

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

print(ans)

Solution (Python):
N, M = map(int, input().split())

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

Solution (Python):
N, M = map(int, input().split(' '))

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

Solution (Python):
n, m = map(int, input().split())





p = (m // 2 - n) // 2
ans = min(n, m//2)
for k in range(max(0, p-10), p+10):
  v = min(n+k, m//2-k)
  if v >= 0:
    ans = max(ans, v)
  
print(ans)

Solution (Python):
a,b = map(int,input().split(" "))
count = 0
if a <= b // 2:
    count += a
    b -= a * 2
    count += b // 4
else:
    count += b // 2
    b -= (b // 2) * 2
    count += b // 4
print(count)

Solution (Python):
N,M = map(int,input().split())
s_num = N
cc_num = M // 2

if min(s_num,cc_num) == cc_num:
    print(cc_num)
    exit()

scc_num = s_num
cc_remains = cc_num - scc_num
sep_2 = cc_remains // 2
scc_num += sep_2
print(scc_num)

Solution (Python):
def inpl(): return [int(i) for i in input().split()]
N, M = inpl()
a = (2*N+M)//4
print(min(a,M//2))

Solution (Python):

"""
N=int(input())

print(800*N-int(N/15)*200)
"""
"""
N=int(input())
S=input()

max_n=0
temp=0
for strng in S:
	if strng=="I":
		temp+=1
		if max_n<temp:
			max_n=temp
	else:
		temp-=1
print(max_n)
"""
"""
N=int(input())

Q=1000000007
p=1
for i in range(1,N+1):
	p*=i
	p=p%Q
print(p%Q)
"""

"""
n=int(input())
S=[input() for i in range(n)]
alphabet_dict={chr(97+i):100 for i in range(26)}
for s in S:
	temp={chr(97+i):0 for i in range(26)}
	for i in s:
		temp[i]+=1

	for key in alphabet_dict.keys():
		if alphabet_dict[key]>temp[key]:
			alphabet_dict[key]=temp[key]
result=""
for item in alphabet_dict.items():
	for i in range(item[1]):
		result+=item[0]
if result=="":
	print("\n")
else:
	print(result)
"""

(N,M) = [int(i)for i in input().split()]

if N>int(M/2):
	print(int(M/2))
else:
	hoge=int(M/2)-N
	print(N+int(hoge/2))

Solution (Python):
import sys

N, M = list(map(int, sys.stdin.readline().strip().split(" ")))

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

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

Solution (Python):
N, M = [int(x) for x in input().split()]

def check(x):
  if M < 2*x:
    return False
  s = max(0, x-N)
  if M < 2*s + 2*x:
    return False
  return True

ok = 0
ng = 2**60
while ng - ok > 1:
  m = (ok + ng) // 2
  if check(m):
    ok = m
  else:
    ng = m
print(ok)

Solution (Python):
N,M = map(int,input().split())

s = N
c = M

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

Solution (Python):
import sys
import collections
import math
from collections import Counter
from collections import deque


N, M = [int(x) for x in input().split()]

scc = 0
n = N
m = M

scc = min(n, m // 2)

n = n - scc
m = m - 2 * scc

if m >= 4:
    scc += (m // 4)

print(scc)
sys.exit(0)

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

Solution (Python):
N, M = map(int, input().split())

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

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

Solution (Python):
import sys
N,M=map(int,input().split())
ans=0
if 2*N>=M:
    print(M//2)
    sys.exit()
ans+=N
M-=2*N
print(ans+M//4)

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

Solution (Python):
N, M = map(int, input().split())

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

Solution (Python):
n, m = map(int, input().split())
ans = min(n, m // 2)
if n < m // 2:
    m = m - n * 2
    ans += m // 4
print(ans)

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

Solution (Python):
f = lambda: list(map(int,input().split()))

n,m = f()
print(m//2 if n>=m else n+(m-2*n)//4)

Solution (Python):
N, M = [int(_) for _ in input().split()]

x = min(N, M // 2)
y = (M - x * 2) // 4

result = x + y

print(result)