import sys



N, M = list(map(int, sys.stdin.readline().strip().split()))



if N >= M // 2:

    print((M // 2))

else:

    ans = N

    r = M - N*2

    ans += r // 4

    print(ans)
import sys



N, M = list(map(int, sys.stdin.readline().split()))



ans = 0

first = min(2 * N, M - M % 2)

M -= first

ans += first // 2

ans += M // 4

print(ans)
import sys

N, M = list(map(int, sys.stdin.readline().strip().split()))
if N >= M // 2:
    print((M // 2))
else:
    ans = N
    r = M - N * 2
    ans += r // 4
    print(ans)

import sys

N, M = list(map(int, sys.stdin.readline().split()))
ans = 0
first = min(2 * N, M - M % 2)
M -= first
ans += first // 2
ans += M // 4
print(ans)

-N, M = list(map(int, sys.stdin.readline().strip().split())) -if N >= M // 2: -    print((M // 2)) -else: -    ans = N -    r = M - N * 2 -    ans += r // 4 -    print(ans) +N, M = list(map(int, sys.stdin.readline().split())) +ans = 0 +first = min(2 * N, M - M % 2) +M -= first +ans += first // 2 +ans += M // 4 +print(ans)