import Data.List
import qualified Data.Vector.Unboxed as V

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 n r = cmbMemo n V.! r
    where cmbMemo :: Int -> V.Vector Int
          cmbMemo 1 = V.fromList [1,1]
          cmbMemo n =
              let memo = cmbMemo (n-1) in
              V.fromList
                   [ mod ((if r == 0 then 0 else memo V.! (r-1)) + (if r == n then 0 else memo V.! r)) 1000000007
                   | r <- [0..n] ]
