main :: IO ()
main = do
  [x,y] <- map (read :: String -> Integer) . words <$> getLine
  print $ ans x y

ans :: Integer -> Integer -> Integer
ans x y
  | (2*x-y) `mod` 3 /= 0   = 0
  | (2*x-y<0) || (2*y-x<0) = 0
  | otherwise = comb (s+t) s
  where
    s = (2*x-y) `div` 3
    t = (2*y-x) `div` 3

comb :: Integer -> Integer -> Integer
comb n 0 = 1
comb 0 k = 0
comb n k = comb (n-1) (k-1) * n `div` k `div` (10^9+7)