def solve():

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

    if M<2*N:

        return M//2

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

print((solve()))
def solve():

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

  if M<=2*N:

    ans = M//2

  else:

    ans = N+(M-2*N)//4

  return ans

print((solve()))
def solve():
    N, M = list(map(int, input().split()))
    if M < 2 * N:
        return M // 2
    return N + (M - 2 * N) // 4


print((solve()))

def solve():
    N, M = list(map(int, input().split()))
    if M <= 2 * N:
        ans = M // 2
    else:
        ans = N + (M - 2 * N) // 4
    return ans


print((solve()))

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