fact 0 = 1
fact n = (n*fact (n-1))

product' [] = 1
product' (x:xs) = (x*product' xs)`mod`(10^9 + 7)

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 $ (product' (f (drop (fromIntegral k) [1..m+k]) [1..m]))`mod`(10^9 + 7)

f ys [] = ys
f (y:ys) (x:xs)
  | y`mod`x /= 0 = y:f ys (x:xs)
  | otherwise = f ((y`div`x):ys) xs