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)

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



ans = min(N,M//2)

if N < M//2:

    M -= 2*N

    ans += M//4



print(ans)

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)

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

-N, M = [int(zz) for zz in input().split()] -ans = 0 -if 2 * N <= M: -    ans += N +N, M = [int(i) for i in input().split()] +ans = min(N, M // 2) +if N < M // 2: -else: -    ans += M // 2 -    M %= 2 -ans += M // 4 +    ans += M // 4