let () =
    let extgcd x y =
        let rec eg r0 r1 a0 a1 b0 b1 =
            if r1 = 0 then a0 else
                let q1 = r0 / r1 in
                eg r1 (r0 mod r1) a1 (a0 - q1 * a1) b1 (b0 - q1 * b1)
        in
        eg x y 1 0 0 1
    in
    let inv x y = (* 1/x in mod y *)
        let c = extgcd x y in
        if c < 0 then c + y else c
    in
    let z = 1_000_000_000 + 7 in
    let ( *@) a b = ((a mod z) * (b mod z)) mod z in
    let binomial a b =
        let rec loop i j acc =
            if j > b then acc else
                let acc = acc *@ i *@ inv j z in
                loop (i - 1) (j + 1) acc
        in
        loop a 1 1
    in
    Scanf.scanf "%d %d" (fun x y ->
        let r =
            if (2*x - y) mod 3 == 0 && (2*y - x) mod 3 == 0 then (
                let a = (2 * x - y) / 3 in
                let b = (2 * y - x) / 3 in
                if a >= 0 && b >= 0 then (
                    binomial (a + b) a
                ) else 0
            ) else 0
        in
        Printf.printf "%d\n" r
    )