import qualified Control.Monad as Monad
import qualified Data.ByteString.Char8 as BS
import qualified Data.Map as Map
import qualified Data.Maybe as Maybe
import qualified Debug.Trace as Trace

factPair :: Integer -> Integer -> Integer -> Integer -> Integer -> (Integer, Integer)
factPair a b tmp factTmp factA
    | ((tmp == a) && (tmp == b)) = (factTmp, factTmp)
    | (tmp == a) = factPair a b (tmp + 1) ((tmp + 1) * factTmp) factTmp
    | (tmp == b) = (factA, factTmp)
    | otherwise = factPair a b (tmp + 1) ((tmp + 1) * factTmp) factA

solve :: Integer -> Integer -> Integer
solve x y
    | (mod (x + y) 3 /= 0) = 0
    | (n < 0 || m < 0) = 0
    | otherwise = combMod (n + m) n (seq factAB factAB)
    where n = div ((2 * y) - x) 3
          m = div ((2 * x) - y) 3
          factAB = factPair n (n + m) 0 1 (-1)

calc :: Integer -> Integer -> Integer -> Integer
calc a b p
    | (b == 0) = 1
    | ((mod b 2) == 0) = (mod (d * d) p)
    | otherwise = mod (a * (calc a (b - 1) p)) p
    where d = calc a (div b 2) p

combMod :: Integer -> Integer -> (Integer, Integer) -> Integer
combMod n m factMN =
    mod ((mod ((factn * (calc factm (db - 2) db))) db) * (calc factm (db - 2) db)) db
    where db = 1000000007
          factn = snd factMN
          factm = fst factMN

main = do
    [x, y] <- map (fst . Maybe.fromJust . BS.readInteger) . BS.words <$> BS.getLine
    let ans = solve x y
    print ans
