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

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

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

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

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

def check(i):
    if M<i*2:
        return False
    if N+(M-i*2)//2<i:
        return False
    return True

r=M//2+1
l=0
while r-l>1:
    mid=(r+l)//2
    
    if check(mid):
        l=mid
    else:
        r=mid
print(l)

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

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

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

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

print(ans)

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

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

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

Solution (Python):
S, c = list(map(int, input().split()))
chalf = c//2
b = 0
if S < chalf:
    b = chalf - -(-(S+chalf)//2)
    print(int(S+b))
elif c < 2:
    print(0)
else:
    print(min(S,chalf))

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

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

if m < 2:
    print(ans)
    sys.exit()

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

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

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

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

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

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

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

    print(n+((m-2*n)//4))

Solution (Python):
import sys
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

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

ans = n
m -= n*2

ans += m//4
print(ans)

Solution (Python):
def main():
    s_shaped_piece, c_shaped_piece = map(int, input().split())
    answer = min(s_shaped_piece, c_shaped_piece // 2)
    c_shaped_piece -= answer * 2
    answer += c_shaped_piece // 4
    print(answer)


if __name__ == '__main__':
    main()

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

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

Solution (Python):

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

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())
cnt = 0

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

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

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

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

Solution (Python):
N, M = map(int, input().split())
v = M - N * 2

if v <= 0:
    print(M // 2)
    exit()
ans = N + v // 4
print(ans)

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s,c=MI()
    ans=min(s,c//2)
    s-=ans
    c-=ans*2
    ans+=c//4
    print(ans)

main()

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

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

ans = 0

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

print(ans)

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


print(r)

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

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

Solution (Python):
from sys import exit

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

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

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

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

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, m = MAP()

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

Solution (Python):
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n, m = MAP()

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

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

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

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

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

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

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

def main():
    N , M = map(int , input().split())
    print(scc(N , M))

if __name__ == '__main__':
    main()

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

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

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

if 2 * n >= m:
  cnt += m // 2

else:
  cnt += n
  m -= 2 * n
  cnt += m//4

print(cnt)

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

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

Solution (Python):

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

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

Solution (Python):

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

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

Solution (Python):
def solve(n, m):
    return m // 2 if 2 * n >= m else (2 * n + m) // 4

_n, _m = map(int, input().split())
print(solve(_n, _m))

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

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

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

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect
from heapq import heappush, heappop

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

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

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

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

    remain_c = M - N * 2

    if remain_c <= 0:
        return M // 2
    else:
        return N + (remain_c // 4)


if __name__ == '__main__':
    res = solve()
    print(res)

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

count = 0

if c / 2 >= s:
    count += s
else:
    count += c // 2

c -= 2 * count

count += c // 4

print(count)

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

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

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

Solution (Python):
s = [int(c) for c in input().split(' ')]

if s[0] > s[1] // 2:
    print(s[1] // 2)
else:
    print(s[0] + (s[1] - 2 * s[0]) // 4)

Solution (Python):
import sys

input = sys.stdin.readline


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

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

if __name__ == '__main__':
    main()

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

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

if __name__ == "__main__":
    main()

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

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

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

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

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

ans = 0

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

print(ans)

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

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

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

DR = [1, -1, 0, 0]
DC = [0, 0, 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 S(): return input()
     
def main():
    N, M = LI()
    cnt = 0
    if 2 * N < M:
        cnt += N
        cnt += (M - 2 * N) // 4
    else:
        cnt += M // 2
    print(cnt)

main()

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())
if 2*n>=m:
    print(m//2)
else:
    k1 = (m-n*2)//4
    k2 = k1+1
    k3 = max(k1-1,0)
    r1 = min(n+k1,(m-k1*2)//2)
    r2 = min(n+k2,(m-k2*2)//2)
    r3 = min(n+k3,(m-k3*2)//2)
    print(max(r1,r2,r3))

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

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

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

print(n + (m // 4))

Solution (Python):
import sys
input = sys.stdin.readline
n,m=map(int,input().split())
print(min(m//2,(n+m//2)//2))

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

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

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

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

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

print(ans)

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

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

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

Solution (Python):
N, M = map(int,input().split())
ans = 0
if N >= M//2:
    ans = M//2
else:
    for i in range(max(0,M//2-N-10), max(0, M//2-N+10)):
        ans = max(ans,min(N+i//2,(M-i)//2))
print(ans)

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

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

ans = 0


if S <= C//2:
    ans += S
    C -= S*2

    if C > 0:
        
        ans += C//4
else:
    ans += (C//2)
        
print(ans)

Solution (Python):
n,m = map(int,input().split())
ans = 0
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())

ans = min(n, m // 2)
m -= ans * 2
print(ans + m // 4)

Solution (Python):
import sys
from io import StringIO
import unittest
import math

def resolve():
    s,c= map(int,input().split())

    if s>=c/2:
        print(str(math.floor(c/2)))
    else:
        zanc = c - (s * 2)
        print(str(s + math.floor(zanc/4)))
        
resolve()

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

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

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

print(ans)

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

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

Solution (Python):


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

ans = 0
ans += min(n, m//2)
n -= ans
m -= ans*2

ans += m//4

print(ans)

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

ans = min(S, C//2)
C -= 2*ans 

if C: 
  ans += C//4
  
print(ans)

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

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

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

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

Solution (Python):

import sys
N, M = map(int, sys.stdin.readline().split())



cnt = min(N, M//2)
N -=cnt
M-=2*cnt

cnt +=M//4
print(cnt)

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

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 < 1 or m < 2:
    print(0)
    quit()

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

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

if n < 1 or m < 2:
    print(0)
    quit()

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

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

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

print(ans)

Solution (Python):
import sys
input = sys.stdin.readline
N, M = [int(x) for x in input().split()]
c_2 = M //2
if c_2 <= N:
    print(min(N, c_2))
    sys.exit()
ans = N
M -= 2 * N
ans += M //4
print(ans)

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

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

print(ans)

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

print(answer)

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, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf')
ans = 0 ;count = 0 ;pro = 1

n,m=map(int,input().split())
k=min(m//2,n)
m-=2*k;n-=k
count+=k

count+=m//4
print(count)

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

Solution (Python):
N, M = map(int, input().split())
Cset=M//2
num = min(N , Cset)
if Cset-N >= 2:
    num+=(Cset-N)//2
print(num)

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
from pprint import pprint
from copy import deepcopy
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
from pprint import pprint


sys.setrecursionlimit(2147483647)
INF = 10 ** 13
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 100000000


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

Solution (Python):
import sys

n, m = map(int, sys.stdin.readline().split())

def main():
    s = n
    c = m
    res = 0
    if c < 2 * s:
        return m // 2
    
    res += s
    c -= 2 * s 
    res += c // 4
    return res

if __name__ == '__main__':
    ans = main()
    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):
n,m = map(int,input().split())
if m // 2 < n:
  print(m//2)
else:
  ans = n
  m -= n*2
  ans += m//4
  print(ans)

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

Solution (Python):


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

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

print(ans)

Solution (Python):
import sys
if sys.platform in ['ios', 'win32', 'darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(x) for x in input().split()]

S, C = MAP()

ans = 0

tmp = min(S//1, C//2)
ans += tmp
S -= tmp*1
C -= tmp*2

if C >=4: ans += C//4

print(ans)

Solution (Python):


S,C = map(int, input().split())

ans = 0

if 2*S <= C:
    ans += S
    C -= 2*S
    ans += max(0,C//4)
else:
    ans += min(S,C//2)

print(ans)

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

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

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

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

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











import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S,C = MI()
    ans = min(S,C//2)
    S-=ans
    C-=2*ans
    if C:
        ans += C//4
    print(ans)
if __name__ == '__main__':
    main()

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

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

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

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

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

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

Solution (Python):
from sys import stdin

a,b = [int(x) for x in stdin.readline().rstrip().split()]

if a > b//2:
    print(b//2)
else:
    print((b+2*a)//4)

Solution (Python):
s,c=map(int,input().split())
if s>=c//2:
    print(c//2)
else:
    c-=s*2
    print(s+c//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,M = map(int,input().split())
ans=0
while True:
    if N > 0 and M >= 2*N:
        ans += N
        M -= 2*N
        N -= N
    elif N > 0 and M < 2*N:
        ans += M//2
        break
    else:
        if M >= 4:
            N += M//4
            M -= M//2
        else:
            break
print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m=map(int,input().split())
    if(m-2*n<=0):
        print(m//2)
        return

    ans=n
    m=m-2*n
    print(ans+m//4)
resolve()

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

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

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

Solution (Python):
def main():
    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)


main()

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

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

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

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

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

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

if n >= c:
    res = c
else:
    res = (n + c) // 2

print(res)

Solution (Python):
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)

Solution (Python):
N, M = map(int, input().split())
l = 0
r = 10 ** 13
while r - l > 1:
    m = (l+r) // 2
    a = max(m - N, 0)
    if M - 2 * a >= 2 * m:
        l = m
    else:
        r = m
print(l)

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

Solution (Python):
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [s_num, c_num] = string_to_int(inputs[0])

    scc_num = 0

    if s_num * 2 <= c_num:
        scc_num += s_num
        c_num -= (s_num * 2)
        scc_num += c_num // 4
    else:
        scc_num += c_num // 2
        c_num -= c_num // 2
        
    return scc_num


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

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

Solution (Python):
import math

s_num, c_num = map(int, input().split())

if c_num <= 2 * s_num:
    
    scc_num = math.floor(c_num / 2)
    print(scc_num)
else:
    
    scc_num = math.floor(s_num + ((c_num - 2 * s_num) / 4))
    print(scc_num)

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

tmp_cnt = M // 2

cnt = min(N, tmp_cnt)

M -= (cnt*2)

cnt += M // 4

print(cnt)