main :: IO ()
main = do
  l1 <- getLine
  let [x, y] = map read $ words l1 :: [Integer]
      (x', y') = (max x y, min x y)
      n = x' - y' -- (y'-n, y'-n)から(x, y)への移動回数
      m = (y' - n)`div`3 -- (y'-n, y'-n)への移動回数/2
      k = m + n
  if y'*2 < x' || (x + y) `mod` 3 /= 0 then
    print 0
  else
    print $ binomialCoefficients (10^9 + 7) (m + k) k

-- gcdExt a b = (x, y, g)
-- ax + by = g = gcd a b
gcdExt :: Integral a => a -> a -> (a, a, a)
gcdExt a 0 = (1, 0, a)
gcdExt a b = (x, y, g)
  where (q, r) = a`divMod` b
        (s, t, g) = gcdExt b r
        x = t
        y = s - q*t

-- ax + kp = 1
modInv :: Integral a => a -> a -> a
modInv p a = x
  where (x, _, _) = gcdExt a p

binomialCoefficients p n k = (npk*modInv p (fact p $ n - k))`mod`p
  where npk = product' p $ drop (fromIntegral k) [1..n]

product' p [] = 1
product' p (x:xs) = (x*product' p xs)`mod`p

fact p 0 = 1
fact p n = (n*fact p (n-1))`mod`p