p = 10^9+7 :: Int

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

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

lucas :: Int -> Int -> Int
lucas x y = prod $ zipWith c (padic x) (padic y)

prod :: [Int] -> Int
prod [] = 1
prod (x:xs) = (`mod` p) $ x * prod xs

padic :: Int -> [Int]
padic n
  | n < p     = [n]
  | otherwise = (n `mod` p) : padic (n `div` p)

c :: Int -> Int -> Int
c n 0 = 1
c 0 k = 0
c n k = c (n-1) (k-1) * n `div` k