! 2019.11.16
!
      program answer
      implicit none
      integer(8) :: X,Y
      integer(8),external :: fac
      integer(8) :: ans
      integer(8) :: N,K
      intrinsic mod,abs
!
      ans = 0
!
      read(*,*) X,Y
!
! X+Y = 3*integer
      if( mod(X+Y,3) == 0) then
! 2X > Y && 2X > Y
        if( 2*X >= Y .and. 2*Y >= X) then
          N = (X+Y)/3
          K = X-N
          ans = fac(N)/(fac(N-K)*fac(K))
        end if
      end if
! ans > 10**9+7
      if( ans > 10**9+7) then
        ans = mod(ans,(10**9+7))
      end if
!
      write(*,*) ans
      end program answer
!
      function fac(N) result(res)
      implicit none
      integer(8) :: N,res
      integer(8) :: i
!
      if(N <= 1) then
        res = 1
      else
        res = 1
        do i=1,N
          res = res * i
        end do
      end if
      end function fac