import Data.Int

modulus :: Int64
modulus = 10000000007

main :: IO ()
main = do
    (x,y) <- (\[a,b] -> (a,b)) . (map read . words)
        <$> getLine :: IO (Int,Int)
    let z = min x y
        s = sum [ a+b | a <- [0..z], b <- [0..z]
                , (a + 2 * b, 2 * a + b) == (x,y)]
    print $ (fromIntegral s :: Int64) `rem` modulus