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

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

fact :: Integer -> Integer
fact n
    | (n == 0) = 1
    | otherwise = n * (fact (n - 1))

solve :: Integer -> Integer -> Integer
solve x y
    | (mod (x + y) 3 /= 0) = 0
    | (n < 0 || m < 0) = 0
    | otherwise = combMod (n + m) n (seq facts facts)
    where n = div ((2 * y) - x) 3
          m = div ((2 * x) - y) 3
          facts = scanl (*) 1 [1..(n+m)]

combMod :: Integer -> Integer -> [Integer] -> Integer
combMod n m facts =
    mod ((mod (((facts !! (fromIntegral n)) * (calc (facts !! (fromIntegral (n - m))) (db - 2) db))) db) * (calc (facts !! (fromIntegral m)) (db - 2) db)) db
    where db = 1000000007

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