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

if n*2 < m:

    while n*2 <= m:

        if m-n - n > 10000:

            m -= 6000

            n += 3000

        else:

            m -= 2

            n += 1

    print((n - 1))

else:

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

if n*2 < m:

    while n*2 <= m:

        if m - 2*n > 100000:

            m -= 60000

            n += 30000

        elif m - 2*n > 10000:

            m -= 6000

            n += 3000

        else:

            m -= 2

            n += 1

    print((n - 1))

else:

    print((m//2))
n, m = list(map(int, input().split()))
if n * 2 < m:
    while n * 2 <= m:
        if m - n - n > 10000:
            m -= 6000
            n += 3000
        else:
            m -= 2
            n += 1
    print((n - 1))
else:
    print((m // 2))

n, m = list(map(int, input().split()))
if n * 2 < m:
    while n * 2 <= m:
        if m - 2 * n > 100000:
            m -= 60000
            n += 30000
        elif m - 2 * n > 10000:
            m -= 6000
            n += 3000
        else:
            m -= 2
            n += 1
    print((n - 1))
else:
    print((m // 2))

-        if m - n - n > 10000: +        if m - 2 * n > 100000: +            m -= 60000 +            n += 30000 +        elif m - 2 * n > 10000: