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):
from math import ceil, floor
n, m = map(int, raw_input().split())
scc = 0
while n > 0 and m >= 2:
	if m >= 2*n:
		scc += n
		m -= 2*n
		n = 0
	elif n > 0 and m >= 2 and m < 2*n:
		scc += m/2
		n -= m/2
		m = m%2 
	if n == 0 and m >= 4:
		n += m/4
		m = int(ceil(float(m)/2))
print scc

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

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

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

Solution (Python):


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

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

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

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

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

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

print(cnt)

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

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

count = 0

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

else:
    count = (c - 1) // 2 if c % 2 == 1 else c // 2
    print(count)

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

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

Solution (Python):
n = list(map(int,input().split()))
x=0
if n[0]*2 < n[1]:
  n[1] -= n[0]*2
  x = n[0] + (n[1]//4)
elif n[0]*2==n[1]:
  x = n[0]
else:
  x = n[1]//2
print(x)

Solution (Python):


def main(N, M):
    if(N>0 and M>2*N):
        print(N+(M-2*N)//4)
    elif(N>0 and M<2*N):
        print(M//2)
    elif(N==0 and M>3):
        print(M//4)
    else:
        print(0)

if __name__ == '__main__':
    N, M = map(int, input().split())

    main(N, M)

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

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

        x=(M-2*N+1)//2
        ans=max(min(N+x//2,(M-x)//2),ans)
print(ans)

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

Solution (Python):

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


if __name__ == "__main__":
    main()

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

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

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

print(ans)

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





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

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

def check(i): 
    S = i
    c = 2 * i
    S -= N 
    S = max(S, 0)
    return M >= (2 * S + c)


la = -1
ua = 10 ** 12
while ua - la > 1:
    mid = (la + ua)//2
    if check(mid):
        la = mid
    else:
        ua = mid

print (la)

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

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

Solution (Python):
s=input().split();a,b=int(s[0]),int(s[1]);ans=0
if 2*a<b:
    ans+=a
    b-=a*2
    ans+=b//4
else:
    ans+=b//2
print(ans)

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

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

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

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

Solution (Python):




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

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

if 2*N >= M:
  print(M // 2)
  exit()
  

var1 = (M - 2*N) // 4 - 1
ans1 = min(N + var1, M - 2*var1)
var2 = (M - 2*N) // 4
ans2 = min(N + var2, M - 2*var2)
var3 = (M - 2*N) // 4 + 1
ans3 = min(N + var3, (M - 2*var3)//2)
ans = max(ans1, ans2, ans3)
print(ans)

Solution (Python):

from decimal import Decimal

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

base_pair = Decimal(min([n,m//2]))
c_left = Decimal(m)-base_pair*2
additional_pair = c_left//4
print(base_pair+additional_pair)

Solution (Python):
n,m=map(int,raw_input().split());print min(m/2+n,m)/2

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

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

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

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

if (N >= M):
    print(M)
    exit()

sub = (M - N) // 2
print(N+sub)

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

ans = 0
buff1 = M - N * 2
buff2 = M // 2
buff3 = min(buff2, N)
if buff2 < N:
    print(buff3)
    exit()
count = buff1 // 4

ans = buff3 + count
print(ans)

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():
  n,m=LI()
  if n*2>m:
    return m//2
  return n+(m-2*n)//4

print(main())

Solution (Python):




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

Solution (Python):
def smaller(x, y):
	if x < y: return x
	return y

N, M = map(int, input().split())
ans = 0
s = smaller(N, M//2)
ans += s
M -= 2*s
ctos = M // 4
ans += ctos
print(ans)

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

Solution (Python):

"""考え方
・"Scc"という組をできるだけ多く作りたい


"""
def solve():
    sN, cN = list(map(int, input().split()))

    if 2*sN < cN:
        
        
        
        ans = sN
        restC = cN - 2*sN  

        
        ans += restC//4
    else:
        
        
        ans = cN//2
    print(ans)


if __name__ == "__main__":
    solve()

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

Solution (Python):

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

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());print(min(2*n+m,m+m)//4)

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

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

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

md = m - 2*n
nd = n - m//2

if md >= 0:
    m = md
    ans = n + m//4

elif nd >= 0:
    ans = m//2

print(ans)

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

md = m - 2*n
nd = n - m//2
if md >= 0:
    m = md
    ans = n + m//4
elif nd >= 0:
    ans = m//2

print(ans)

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

Solution (Python):
List=[int(j) for j in input().split()]
a=List[0]
b=List[1]

if b>2*a:
    c=b-2*a
    d=c//4
    print(a+d)
else:
    print(b//2)

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()
    cnt = min(n*2, m)
    ans = cnt//2
    remain = m - ans*2


    print(ans + remain//4)

solve()

Solution (Python):
import math

ns, nc = map(int, input().split())
if ns >= nc // 2:
    print(nc // 2)
else:
    x = math.ceil((nc - 2 * ns) / 4)
    ns += x
    nc -= 2 * x
    print(min(ns, nc // 2))

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

num = min(N, M // 2)

print((M - num * 2) // 4 + num)

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) 

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


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

    ans = M//2
print(ans)

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

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

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())
print(min(n,m//2)+max(0,(m-2*n)//4))

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

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 = [int(i) for i in input().split()]
 
if 2 * N <= M:
    print((M + 2*N) // 4)
else:
    print(M // 2)

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

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

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

m //= 2

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

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

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

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

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

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

Solution (Python):

def read_input():
    n, m = map(int, input().split())
    return n, m


def submit():
    n, m = read_input()

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

if __name__ == '__main__':
    submit()

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

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

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

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

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

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

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

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

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

if N < M//2:
    scc_min = max(1, N)
else:
    scc_min = M//2
scc_max = N + M//2

while scc_min < scc_max:
    scc = (scc_min + scc_max) // 2
    excess_c = M - scc*2
    if scc_min + 1 == scc_max:
        break
    if excess_c > 0 and excess_c//2 + N >= scc:
        scc_min = scc
    else:
        scc_max = scc - 1

excess_c = M - scc_max*2
if excess_c > 0 and excess_c//2 + N >= scc_max:
    print(scc_max)
else:
    print(scc_min)

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

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

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
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 _I(): return int(sys.stdin.readline())
def _F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

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

print(ans)

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

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

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

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

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

Solution (Python):
from math import floor
n,m=map(int,input().split())
a=floor(m/2)
if n>a:
    print(a)
else:
    print(floor((n+a)/2))

Solution (Python):
if __name__ == '__main__':
    s_count, c_count = map(int, input().split())
    if s_count > c_count // 2:
        print(c_count // 2)
    else:
        print(s_count + (c_count - s_count * 2) // 4)

Solution (Python):
import sys

def main():
    input = sys.stdin.readline
    N, M = map(int, input().split())

    if N >= M // 2:
        ans = M // 2
        

        

        return ans

    else:
        ans = N
        M -= 2 * N

        ans += M // 4

        return ans


if __name__ == '__main__':
    print(main())

Solution (Python):
from functools import reduce
import math

def main():
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    

    
    
    
    
    N,M = (int(_) for _ in input().split())
    if(M<2):
        print(0)
        exit()
    if N>M//2:
        N = N-(N - M//2)
    ans = (N*2 + M)//4
    
    
    
    
    
    
    
    
             
    print(ans)
    
if __name__ == '__main__':
    main()

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

ans = 0

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






if c >= 4:
  ans += c // 4
  
print(ans)

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

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

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

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

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

Solution (Python):


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

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

Solution (Python):
def scc_puzzle(N: int, M: int) -> int:
    if 2 * N < M:
        
        
        return N + (M - 2 * N) // 4

    return M // 2


if __name__ == "__main__":
    N, M = map(int, input().split())
    ans = scc_puzzle(N, M)
    print(ans)

Solution (Python):


















import math
import copy
from collections import defaultdict, Counter

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right


def i_inpl(): return int(input())
def s_inpl(): return map(int,input().split())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

N, M = s_inpl()

diff = M-N*2

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

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

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

Solution (Python):
N, M =list(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*2<m:
    ans=n;m-=n*2
    ans+=m//4
else: ans=m//2
print(ans)

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

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

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

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

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

print(count)

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

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

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

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

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

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

if C<=2*S:
    print(C//2)
else:
    ans=S
    for x in range(max(0,(C-2*S)//4-10),(C-2*S)//4+10):
        if C-2*x<2*(S+x):
            break
        ans=S+x
    print(ans)

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

def f():
    if n*2 > m:
        return m//2
    
    return n + (m-n*2) // 4

print(f())

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

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

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

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

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


if __name__ == "__main__":
    main()

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007


def A():
    n = II()
    ans = n * 800
    print(ans-(n//15)*200)
    return


def B():
    n = II()
    print(math.factorial(n)%mod)
    return


def C():
    n, m = LI()
    if n >= m // 2:
        print(m // 2)
        return
    else:
        m -= 2 * n
        print(n+m//4)
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    C()

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007


def A():
    n = I()
    print(n*800-200*(n//15))


def B():
    k = I()
    ans = 0
    for i in range(1,k):
        for j in range(i+1,k+1):
            if (i%2)^(j%2):
                ans += 1
    print(ans)


def C():
    x,t = LI()
    print(max(0,x-t))


def D():
    n = I()
    ans = 1
    for i in range(1,n+1):
        ans *= i
        ans %= mod
    print(ans)


def E():
    x,y,s,t = LI()
    return


def F():
    n = I()
    x = LI()
    a = sorted(x)
    for i in range(n):
        j = bisect.bisect_left(a,x[i])
        if j >= n//2:
            print(a[n//2-1])
        else:
            print(a[n//2])


def G():
    n,m = LI()
    if m <= 2*n:print(m//2)
    else:
        ans = n
        m -= 2*n
        ans += m//4
        print(ans)


def H():
    return

def J():
    return

def K():
    return


if __name__ == "__main__":
    G()

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

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

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, raw_input().split())
ans = min(N, M/2)
M -= ans*2
if M>0:
  ans += M/4
print ans

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







x=max(0,(M-N*2)//4)

print(min(N+x,M//2))

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

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

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

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

Solution (Python):


"""
Scc Puzzle
"""

def answer():
    """
    Sが余るときとcが余るときに分けて考える。
    """
    S, c = map(int, input().split())

    if S >= c//2:
        return int(c//2)

    return int(S + (c - S*2) // 4)


def main():
    """
    答えを出力
    """
    print(answer())


if __name__ == '__main__':
    main()

Solution (Python):
def main():
    n, m = map(int, input().split())
    print(solve(n, m))

def solve(n, m):
    x = n * 2 + m
    return min(x // 4, m // 2)

main()

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

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

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

print(ans)

Solution (Python):

import sys

def main():
	s_num, c_num = map(int, input().split(" "))
	
	counts = 0
	if c_num >= (s_num * 2):
		counts = counts + s_num
		c_num = c_num - (s_num * 2)
		s_num = 0
	elif s_num != 0:
		tmp = c_num // 2
		counts = counts + tmp
		s_num = s_num - tmp
		c_num = c_num - (tmp * 2)
		
	tmp = c_num // 4
	
	print(counts + tmp)
	
if __name__ == "__main__":
	main()

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

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())
if 2*N == M:
    print(N)
elif 2*N < M:
    print(N+(M-2*N)//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):

from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007






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

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

x = c // 2
cnt = min(s, x)
c -= cnt * 2
    
if c > 3:
    cnt += c // 4
    
print(cnt)

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

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

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

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

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

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

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

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

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

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

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

Solution (Python):
def solve(N, M):
    ans = min(N, M // 2)
    M -= ans * 2
    ans += M // 4
    return ans


if __name__ == "__main__":
    N, M = map(int, input().split(" "))
    print(solve(N, M))

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

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

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

Solution (Python):
def num(N, M):
    return min(N, M//2)

N, M = map(int, input().split())
if 2*N >= M:
    print(M//2)
else:
    a = (M - 2*N) // 4
    cand = []
    for i in range(a, a+1):
        cand.append(num(N+i, M-2*i))
    print(max(cand))

Solution (Python):
def num(N, M):
    return min(N, M//2)

N, M = map(int, input().split())
if 2*N >= M:
    print(M//2)
else:
    a = (M - 2*N) // 4
    cand = []
    for i in range(a, a+4):
        cand.append(num(N+i, M-2*i))
    print(max(cand))

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

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

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

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

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

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

ans = 0

if N*2 <= M:
    ans += N
    M -= 2*N
    N = 0
    if M >= 4:
        ans += math.floor(M / 4)
else:
    ans += M/2
print(int(ans))

Solution (Python):


import sys


INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(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()


n, m = LI()

scc = min(n, m // 2)
n, m = 0, m - 2 * scc
scc2 = m // 4

print(scc + scc2)

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

ans = min(S,C//2)
if C >= S*2:
    C = C - S*2
    ans += C//4

print(ans)

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

ans=0
if 2*n<=m:
    ans+=n
    n=0
    m-=2*ans
elif 1<=n and 2<=m:
    ans+=m//2
    n-=m
    m-=(m//2)*2
   

ans+=m//4

print(ans)

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

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

Solution (Python):
int_s, int_c = map(int, input().split())


if int_s * 2 == int_c:
    print(int_s)
elif int_s * 2 > int_c:
    print(int_c // 2)
else: 
    zan_c = int_c - int_s * 2
    print(int_s + zan_c // 4)

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

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