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

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 -> Integer -> Integer
fact n m factm
    | (n == m) = factm
    | otherwise = fact n (m + 1) ((m + 1) * factm)

makeNextFact :: (Integer, Integer) -> Integer -> (Integer, Integer)
makeNextFact (a, b) c = (a + 1, b * c)

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


combMod :: Integer -> Integer -> Integer -> Integer -> Integer -> Integer
combMod n m factn factm factnsm =
    mod ((mod ((factn * (calc factm (db - 2) db))) db) * (calc factm (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
