program kadai
    implicit none
integer(8)  ::  x,y,i
integer(8)  ::  newx,newy
integer(8),allocatable  ::  ue(:),shita1(:),shita2(:)
integer(8)  ::  ans

read(*,*) x,y

newx=-x+2*y
newy=2*x-y

if (mod(newx,3) /= 0 .or. mod(newy,3) /=0 .or. newx<0 .or. newy<0) then
    write(*,*) 0
    stop
end if
newx=newx/3
newy=newy/3

if (newx==0 .and. newy==0) then
    write(*,*) 0
    stop
end if

if (newx==0) then
    write(*,*) newy
    stop
end if

if (newy==0) then
    write(*,*) newx
    stop
end if

allocate(ue(newx+newy))
allocate(shita1(10**8))
allocate(shita2(newx+newy))

ue(1)=1
shita1(1)=1
shita2(1)=1

do i=2,newx+newy
    ue(i)=mod(ue(i-1)*i,10**9+7)
    shita1(i)=10**9+7-mod(shita1(mod(10**9+7,i)) * ((10**9+7)/i) , 10**9+7)
    shita2(i)=mod(shita2(i-1)*shita1(i),10**9+7)
end do

ans=mod(ue(newx+newy)*mod(shita2(newx)*shita2(newy),10**9+7),10**9+7)
write(*,*) ans

stop
contains
end program kadai
