import Data.List

main = do
  x:y:_ <- map read . words <$> getLine :: IO [Int]
  putStrLn $ show $ path x y

path :: Int -> Int -> Int
path x y | mod (x+y) 3 /= 0 = 0
         | otherwise = let n = div (x+y) 3 in
                       if (x-n) < 0 || (y-n) < 0 then 0
                       else cmb n (x-n)

cmb :: Int -> Int -> Int
cmb n r = times (foldl times 1 [(n-r+1)..n]) (foldl times 1 $ map (invMod 1000000007) [1..r])
    where times x y = mod (x * y) 1000000007

invMod :: Int -> Int -> Int
invMod n x = mod (xgcd n x !! 1) n
xgcd :: Int -> Int -> [Int]
xgcd a b |     a < b = xgcd b a
         | otherwise = xgcdRec [1,0,0,1] a b
         where xgcdRec m a 0 = m
               xgcdRec [x,y,x',y'] a b = let d = div a b in xgcdRec [x',y',x-d*x',y-d*y'] b (mod a b)
