module Factwithmod
  implicit none
  integer(16),allocatable,dimension(:)::Kaijo
  contains
subroutine initiationFactorial(maxnum,mo)
  implicit none
  integer(16)::maxnum
  integer(16)::mo
  integer(16)::i

  allocate(Kaijo(0:maxnum))
  Kaijo(0)=1
  do i=1,maxnum
    Kaijo(i)=mod(Kaijo(i-1)*i,mo)
  end do
end subroutine

function combination(n,k,l)
implicit none
integer(16),intent(in)::n,k,l
integer combination

combination=mod(Kaijo(N)*inv(Kaijo(K),l)*inv(Kaijo(N-K),l),l)

end function

function inv(K,L)
integer(16),intent(in)::k,l
integer(16) l2,y
integer(16) inv
inv=1
l2=l-2
y=k
do
  if(mod(l2,2)==1)inv=mod(inv*y,l)
  y=mod(y*y,l)
  l2=l2/2
  if(l2==0)exit
end do
end function

function permutation(n,k,mo)
implicit none
  integer(16)::n,k
  integer(16)::mo,permutation
  permutation=mod(Kaijo(N)*inv(Kaijo(N-K),mo),mo)
end function
end module

program abc145d
    use Factwithmod
    integer(16)::X,Y
    integer(16)::mo=10**9+7
    read*,X,Y
    if(mod(X+Y,3)/=0)then
        print"(I0)",0
        stop
    endif
    if(2*Y-X<0)then
        print"(I0)",0
        stop
    endif
    if(2*x-Y<0)then
        print"(I0)",0
        stop
    endif
    call initiationFactorial(X+Y,mo)
    print"(I0)",combination((X+Y)/3,(2*Y-X)/3,mo)
contains
end