def main():
    N, M = map(int, input().split())

    cnt = 0
    cnt = min(N, M//2)
    M -= 2*cnt
    if M > 0:
        cnt += M//4
    print(cnt)
        
if __name__ == "__main__":
    main()
423c16e92770fba9a5f1f05a01cca47914245c4e
<mask token>

def main():
    N, M = map(int, input().split())
    cnt = 0
    cnt = min(N, M // 2)
    M -= 2 * cnt
    if M > 0:
        cnt += M // 4
    print(cnt)


<mask token>

def main():
    N, M = map(int, input().split())
    cnt = 0
    cnt = min(N, M // 2)
    M -= 2 * cnt
    if M > 0:
        cnt += M // 4
    print(cnt)


if __name__ == '__main__':
    main()

def main():
    N, M = map(int, input().split())

    cnt = 0
    cnt = min(N, M//2)
    M -= 2*cnt
    if M > 0:
        cnt += M//4
    print(cnt)
        
if __name__ == "__main__":
    main()