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

if 2*N < M:

    extra = (M - 2*N) // 4

    ans = N + extra

else:

    ans = M // 2

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

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

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

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