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 () =
        for i = 0 to z - 1 do
            let c = inv i z in
            if c < 0 then Printf.printf "%d %d!!\n%!" i c
        done
    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
    let main () =
        let x, y = Scanf.sscanf (read_line ()) "%d %d" (fun x y -> x, y) in
        let ans = if (2*y - x) mod 3 <> 0 ||
           (2*x - y) mod 3 <> 0 then 0 else (
               let m = (2 * y - x) / 3 in
               let n = (2 * x - y) / 3 in
               if m < 0 || n < 0 then 0 else
                binomial (m + n) m
        )
        in
        Printf.printf "%d\n" ans
    in
    main ()