[<AutoOpen>]
module Program

open System

let read f = stdin.ReadLine() |> f
let reada f = stdin.ReadLine().Split() |> Array.map f
let reads f = stdin.ReadLine().Split() |> Array.toList |> List.map f

let MOD = 1000000007

/// n! (mod p)
/// O(n)
let inline factorial n p =
    if n = LanguagePrimitives.GenericZero then
        1L
    else
        List.fold (fun s x -> s * x % int64 p) 1L [1L .. int64 n]
    |> int

/// x ^ n (mod p)
/// O(log n)
let inline pownMod x n p =
    let rec loop x n p =
        if n = 1L then
            x
        elif n % 2L = 0L then
            loop (x * x % p) (n / 2L) p
        else
            loop (x * x % p) (n / 2L) p * x % p
    loop (int64 x) (int64 n) (int64 p)
    |> int

/// C(n, k) (mod p)
/// O(n + k + log p)
let inline comb n k p =
    let zero = LanguagePrimitives.GenericZero
    let one = LanguagePrimitives.GenericOne
    if n < zero || k < zero || n < k then
        0L
    elif n = zero || k = zero then
        1L
    else
        let a = factorial n p
        let b = factorial k p
        let c = factorial (n - k) p
        let pb = pownMod b (p - one - one) p
        let pc = pownMod c (p - one - one) p
        ((int64 a * int64 pb % int64 p) * int64 pc) % int64 p
    |> int

[<EntryPoint>]
let main _ =
    let [X;Y] = reads int

    if (X + Y) % 3 <> 0 then
        0
    else
        let m = (2 * X - Y) / 3 |> int64
        let n = (-X + 2 * Y) / 3 |> int64
        comb (m + n) n MOD
    |> printfn "%i"

    0