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

cnt = 0

if m // 2 >= n:

    cnt += n

    m -= n*2

else:

    cnt += m//2

    n -= m//2

    m -= m



#print(n,m)

cnt += m//4



print(cnt)

#from statistics import median

#import collections

#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]

#from fractions import gcd

#from itertools import combinations # (string,3) 3回

#from collections import deque

from collections import deque,defaultdict

#import bisect

#

#    d = m - k[i] - k[j]

#    if kk[bisect.bisect_right(kk,d) - 1] == d:

#

#

#

# pythonで無理なときは、pypyでやると正解するかも！！

#

#



import sys

sys.setrecursionlimit(10000000)

mod = 10**9 + 7

#mod = 9982443453

def readInts():

  return list(map(int,input().split()))

def I():

  return int(eval(input()))

n,m = readInts()

cnt = 0

if m //2 >= n:

    cnt += n

    m -= n * 2

else:

    cnt += m//2

    n -= m//2

    m -= m

cnt += m//4 # if のとき

print(cnt)

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

# from statistics import median
# import collections
# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
# from fractions import gcd
# from itertools import combinations # (string,3) 3回
# from collections import deque
from collections import deque, defaultdict

# import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
import sys

sys.setrecursionlimit(10000000)
mod = 10**9 + 7
# mod = 9982443453
def readInts():
    return list(map(int, input().split()))


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


n, m = readInts()
cnt = 0
if m // 2 >= n:
    cnt += n
    m -= n * 2
else:
    cnt += m // 2
    n -= m // 2
    m -= m
cnt += m // 4  # if のとき
print(cnt)

-n, m = list(map(int, input().split())) +# from statistics import median +# import collections +# aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0] +# from fractions import gcd +# from itertools import combinations # (string,3) 3回 +# from collections import deque +from collections import deque, defaultdict + +# import bisect +# +#    d = m - k[i] - k[j] +#    if kk[bisect.bisect_right(kk,d) - 1] == d: +# +# +# +# pythonで無理なときは、pypyでやると正解するかも！！ +# +# +import sys + +sys.setrecursionlimit(10000000) +mod = 10**9 + 7 +# mod = 9982443453 +def readInts(): +    return list(map(int, input().split())) + + +def I(): +    return int(eval(input())) + + +n, m = readInts() -# print(n,m) -cnt += m // 4 +cnt += m // 4  # if のとき