program knight
  implicit none
  integer(8), parameter :: md = 1000000007_8
  integer :: x, y
  integer(8) :: n, k, i, num = 1_8, den = 1_8
  read(*,*) x, y
  if (2*y-x < 0 .or. 2*x-y < 0 .or. mod(x+y,3) /= 0) then
    write(*,'(i0)') 0
    stop
  end if
  n = int((x+y)/3,8)
  k = int((2*y-x)/3,8)
  do i = 1_8, k
    num = mod(num*(n-i+1_8),md)
    den = mod(den*i,md)
  end do
  write(*,'(i0)') mod(num*inv(den),md)
contains
  function inv(n) result(y)
    integer(8), intent(in) :: n
    integer(8) :: a, b, x, y, t, q
    a = modulo(n,md)
    b = md
    x = 0_8
    y = 1_8
    do while (b /= 0_8)
      q = a/b
      t = b
      b = mod(a,b)
      a = t
      t = y
      y = x
      x = t-q*x
    end do
    y = modulo(y,md)
  end
end program knight