program knight
    implicit none
    integer(8)::x, y
    integer(8):: i, d
    read*, x, y

    if (mod(x+y,3) /= 0) then
        print*, 0
        stop
    end if

    d = (x+y)/3
    x = x - d
    y = y - d

    if (x < 0 .or. y < 0) then
        print*, 0
        stop
    end if

    if (x==0 .or. y==0) then
        print*, 1
        stop
    end if

    print*, nikou(x+y, x)

    contains
    function nikou(a,b) result(ret)
        integer(8):: a,b
        integer(8):: ret
        integer(8), parameter:: md = 1000000007
        integer(8), allocatable:: fi(:), i_fi(:)
        
        allocate(fi(a), i_fi(a))
        fi(1) = 1

        do i=2,a
            fi(i) = mod(fi(i-1)*i, md)
        end do

        do i=1,max(b,a-b)
            i_fi(i) = inv((fi(i)),md)
        end do

        ret = mod(mod(fi(a)*i_fi(b),md)*i_fi(a-b),md)
    end function


    function inv(x, md) result(ret)
        integer(8):: x, md, ret, power

        power = md-2
        ret = 1

        do while(power > 0)
            if (mod(power,2) == 1) ret=mod(ret*x,md)
            x=mod(x*x,md)
            power = power/2
        end do
    end function
end program knight