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

if s*2 <= c:
    add_pair = 0
    if c-s*2 >=3:
        add_pair = int((c-s*2)/4)
    print(s+add_pair)

else:
    print(int(c/2))

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

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

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


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

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

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

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

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

print(ans)

Solution (Python):


import sys
import os


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

S_num = N
c_num = M


if c_num // 2 <= S_num:
    print(c_num // 2)
else:
    
    all = S_num
    
    c_num -= (2 * S_num)

    
    all += c_num // 4

    print(all)

Solution (Python):
s_num, c_num = map(int, input().split())

ans = 0

if s_num * 2 >= c_num:
    ans = c_num // 2
else:
    ans += s_num
    c_num -= s_num * 2
    ans += c_num // 4

print(ans)

Solution (Python):
s_num, c_num = map(int, input().split())

ans = 0

if s_num * 2 >= c_num:
    ans = min(s_num, c_num // 2)
else:
    ans += s_num
    c_num -= s_num * 2
    ans += c_num // 4

print(ans)

Solution (Python):

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

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


X = 0
if c > S*2:
    X += S
    c -= 2*S
    X += int(c/4)
    print(X)
else:
    print(int(c/2))

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

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

Solution (Python):


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

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

Solution (Python):
if __name__ == "__main__":
    inp = [int(i) for i in input().split()]
    N = inp[0]
    M = inp[1]
    if 2*N >= M:
        print(M//2)
    else:
        print(N+(M-2*N)//4)

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

Solution (Python):



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

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

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

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

ans += m // 4

print(ans)

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

sa = M - 2*N
x = 0

if sa <0:
    x = M//2
else:
    x = N + sa//4

print(x)

Solution (Python):
n,m=map(int,raw_input().split())
s=0
if m>=2*n:
    s+=n
    s += (m - 2 * n) / 4

else:

    s+=m/2
    
print s

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

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

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

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

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

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

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

print(a)

Solution (Python):

import sys
import math



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

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

    
    print(K)


if __name__ == '__main__':
    main()

Solution (Python):
import sys
import numpy as np
from math import *
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, M] = [int(input_raw[0]), int(input_raw[1])]
    T = M - 2 * N
    if T < 0:
        scc_num = int(M/2)
    else:
        scc_num = N + int(T/4)

    print scc_num

if __name__ == '__main__':
    main()

Solution (Python):


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

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

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

Solution (Python):




s, c = map(int, raw_input().split())
ans = 0

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

print ans

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

Solution (Python):
NM = raw_input().split()
cPairs = int(NM[1]) / 2
SCCby1S2C = min([int(NM[0]),cPairs])
NM[0] = int(NM[0]) - SCCby1S2C
cPairs = cPairs - SCCby1S2C
SCCby4C = cPairs / 2
print SCCby1S2C + SCCby4C

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

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

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

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


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

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

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

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

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

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


def check(a):
    b = M - 2 * a
    if b < 0:
        return False
    return b // 2 + N >= a

left, right = 0, M
while right - left > 1:
    mid = (left + right) // 2
    if check(mid):
        left = mid
    else:
        right = mid
print(left)

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

Solution (Python):



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

    result = s - int(c / 2)

    if result < 0:
        r = result * -2
        r = int(r / 4)
        print(s + r)
    else:
        print(s - result)

if __name__ == '__main__':
    main()

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

print(count)

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


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

else:
	cnt = M//2

print cnt

Solution (Python):
a=input().split()
N=int(a[0])
M=int(a[1])
ans=0

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

print(int(ans))

Solution (Python):



S,C = map(int, raw_input().split())
SCC = 0
if(C>=2*S):
    SCC += S
    C = C-2*S
    S = 0
    SCC += C/4
else:
    SCC = C/2
print(SCC)

Solution (Python):
import math
def input_parser():
    N, M=(int(str) for str in input().split())
    return N, M
N, M=input_parser()
if N*2>M:
    ans=math.floor(M/2)
else:
    remc=M-N*2
    ans=N+math.floor(remc/4)

def output_parser(output):
    print(output)

output_parser(ans)

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

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

Solution (Python):



def main():
    n, m = map(int, input().split())
    c_num = n * 2

    if m - c_num < 0:
        result = m / 2
    else:
        result = n + ((m - c_num) / 4)
    print(int(result))


if __name__ == '__main__':
    main()

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

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

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

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

if(s < c/2):
    s_pair = s
    c_pair = (c - s*2)/4
else:
    s_pair = c/2
    c_pair = 0

print s_pair + c_pair

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

Solution (Python):
data = input().split()
N = int(data[0])
M = int(data[1])

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

print(sum)

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


def main(s, c):
    if s >= c // 2:
        return c // 2
    else:
        ret = s
        c -= s * 2
        ret += c // 4
        return ret


ans = main(s, c)
print(ans)

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

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

print(ans)

Solution (Python):
MOD = 1000000007

l = input().split()
s = int(l[0])
c = int(l[1]) // 2

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


print(ans)

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

Solution (Python):

INF=10**10

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

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

print(str(Scc))

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

print(str(Scc))

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

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

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

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

Solution (Python):
def solve(n, m):
    if 2 * n <= m: 
        r1 = n
    else:
        r1 = m // 2
    m -= 2 * r1

    r2 = m // 4

    res = r1 + r2
    return res

n, m = input().split()
n = int(n)
m = int(m)
print(solve(n, m))

Solution (Python):
import sys
import math

n, m = [int(x) for x in sys.stdin.readline().split()]

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

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

Solution (Python):
def compare(a, b): 
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')
	return a_ > b_

def divide(num, den): 
	quo = ''; resi = 0
	digit = len(num) if int(num[0]) >= den else len(num)-1
	for i in range(len(num)):
		temp = (int(num[i])+resi*10)//den

		resi = (int(num[i])+resi*10)%den

		quo += str(temp)
	return quo

def multi(a, n):
	s = ''; resi = 0
	for i in range(len(a))[::-1]:
		temp = (int(a[i])*n + resi)%10

		resi = (int(a[i])*n + resi)//10

		s = str(temp) + s
	return s


def plus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; resi = 0
	for i in range(l)[::-1]:
		temp = (int(a_[i]) + int(b_[i]) + resi)%10

		resi = (int(a_[i]) + int(b_[i]) + resi)//10

		s = str(temp) + s
	return s


def minus(a, b):
	l = max(len(a), len(b))
	a_ = a.rjust(l, '0')
	b_ = b.rjust(l, '0')

	s = ''; bollow = 0
	for i in range(l)[::-1]:
		temp = int(a_[i]) - int(b_[i]) - bollow

		bollow = 0
		if temp >= 0:
			s = str(temp) + s
		else:
			bollow = 1
			s = str(temp + 10) + s
	return s


s, c = input().split()
if compare(s, divide(c, 2)) or s == c:
	print(int(divide(c, 2)))
else:
	print(int(plus(s, divide(minus(c, multi(s, 2)), 4))))

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

Solution (Python):
import sys

def makePuzzle():
    count_Scc = 0
    tmp = sys.stdin.readlines()
    num_s, num_c = tmp[0].split(" ")
    num_s = int(num_s)
    num_c = int(num_c)

    if num_c-num_s*2>=0:
        count_Scc = num_s
        num_c = num_c - num_s*2
        count_Scc = count_Scc + num_c//4
    else:
        count_Scc = num_c//2

    return count_Scc

if __name__=="__main__":
    print(makePuzzle())

Solution (Python):
N, M = map(int, input().split(' '))
def sunuke_f3(n, m) :
    if n >= m :
        return(m//2)
    else :
        if 2*n < m :
            return(n + (m-2*n)//4)
        else :
            return(m//2)
print(sunuke_f3(N, M))

Solution (Python):

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

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

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

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

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

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

Solution (Python):


import sys

def main(argv):
    for line in sys.stdin:
        n, m = map(lambda i: int(i), line.split(' ', 2))

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

if __name__ == "__main__":
    main(sys.argv)

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

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

Solution (Python):
l=raw_input().split()
M=int(l[0])
N=int(l[1])

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

print(A)

Solution (Python):

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

Solution (Python):
N,M = input().split()
s0,c0 = int(N),int(M)
c1 = c0 - s0*2 
c2 = int(c1/4) if c1 >= 0 else 0 
s = s0 if s0 < c0 else c0//2
print(s+c2)

Solution (Python):

n = list(map(int, input().split()))
s = n[0]
c = n[1]

ans = 0
if s * 2 < c:
    ans = s
    c = c - (s * 2)
else:
    
    ans = int(c / 2)
    print(str(ans))
    quit()

ans += int(c / 4)
print(str(ans))

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

Solution (Python):
line = raw_input()
inputs = line.split(" ")
N, M = [int(i) for i in inputs]
assert(1 <= N <= 1e12)
assert(1 <= M <= 1e12)
if M >= 2*N:
    print N + (M - 2*N)/4
else:
    print M/2

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

NS = N
Nc = M
Ncc = Nc // 2

if NS < Ncc:
    
    Nc_single = Nc - NS * 2
    ans = NS + Nc_single // 4
else:
    
    ans = Ncc

print(ans)

Solution (Python):
nb_s, nb_c = map(int, input().split())

if nb_s*2 > nb_c:
    print(nb_c // 2)
else:
    nb_used_c = 2*nb_s

    nb_rest_c = int(nb_c) - nb_used_c

    print(int(nb_s) + (nb_rest_c // 4))

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

scc = 0

if s >= c//2:
    scc = c//2
else:
    scc += s
    c -= s*2
    scc += c//4

print(scc)

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

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

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

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


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

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

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

k = m // 2
r = m % 2
if n >= k:
    print(k)
else:
    print(n + (k-n) // 2)

Solution (Python):
l = input().split()
n = int(l[0])
m = int(l[1])
a = 0

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

Solution (Python):
S, C = [int(i) for i in input().rstrip().split()]
rest_C = C - S * 2
sum = 0
if rest_C < 0:
    print(C // 2)
else:
    print(S + rest_C // 4)

Solution (Python):
from sys import stdin

s, c = map(int, stdin.readline().split())

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

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

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

Solution (Python):
data = input().split()
N = int(data[0])
M = int(data[1])

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

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

print(count)

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

Solution (Python):

N, M = [int(n) for n in input().split()]
scc = 0

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

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

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

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

Solution (Python):

def getLnInputs():
    return input().split()


def getLnIntInputs():
    return list(map(int, getLnInputs()))


def main():
    N, M = getLnIntInputs()
    if M <= N * 2:
        print(M // 2)
        return

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

    return


main()

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

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

L = M//2
if N >= L:
    print(L)
else:
    print((N+L)//2)

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

min_n = n
min_m = m // 2
ans = min(min_n, min_m)

if min_n < min_m:
    m -= min_n * 2
    ans += m // 4

print(ans)

Solution (Python):
from collections import defaultdict


def main():
    N, M = map(int, input().split())
    ans = min(N, M // 2)
    N -= ans
    M -= (ans * 2)

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

if __name__ == '__main__':
    main()

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

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

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

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

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

def calc(n,m):
  if n>m//2:
    return m//2
  else:
    tcnt = n
    m = m - 2*n
    return tcnt + m//4

print(calc(n,m))