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



if n > (m+n)/3:

    print((m//2))

    exit()

if m > 10000000000:

    print((m//4))

    exit()



while n <= (n+m)/3:

    n += 1

    m -= 2



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



if n > (m+n)/3:

    print((m//2))

    exit()



ans = n

m -= 2*n

ans += m//4

print(ans)
n, m = list(map(int, input().split()))
if n > (m + n) / 3:
    print((m // 2))
    exit()
if m > 10000000000:
    print((m // 4))
    exit()
while n <= (n + m) / 3:
    n += 1
    m -= 2
print((n - 1))

n, m = list(map(int, input().split()))
if n > (m + n) / 3:
    print((m // 2))
    exit()
ans = n
m -= 2 * n
ans += m // 4
print(ans)

-if m > 10000000000: -    print((m // 4)) -    exit() -while n <= (n + m) / 3: -    n += 1 -    m -= 2 -print((n - 1)) +ans = n +m -= 2 * n +ans += m // 4 +print(ans)