[<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 = 1000000007L

/// n! (mod p) を求める
/// O(n)
let rec factorial n p =
    let rec loop a n p =
        match n with
        | 0L | 1L -> a
        | _ -> loop ((a * n) % p) (n - 1L) p
    loop 1L n p

/// x ^ n (mod p) を求める
/// O(log n)
let rec pownMod x n p =
    if n = 0L then
        1L
    elif n % 2L = 0L then
        let a = pownMod x (n / 2L) p
        (a * a) % p
    else
        let a = pownMod x (n - 1L) p
        (x * a) % p

/// C(n, k) (mod p) を求める
/// O(n + k + log p)
let comb n k p =
    if n < 0L || k < 0L || n < k then
        0L
    elif n = 0L || k = 0L then
        1L
    else
        let a = factorial n p
        let b = factorial k p
        let c = factorial (n - k) p
        let pb = pownMod b (p - 2L) p
        let pc = pownMod c (p - 2L) p
        // (a * pownMod b (p - 2L) p * pownMod c (p - 2L) p) % p
        ((a * pb % p) * pc) % p

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

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

    0