let m = 1000000007
let ( * ) a b = a * b mod m
let rec f n a = if n <= 1 then a else f (n - 1) (a * n)
let rec g b n = if n <= 0 then 1 else let p = g b (n / 2) in p * p * if n mod 2 = 0 then 1 else b
let c n r = if n < r || n < 0 || r < 0 then 0 else f n 1 * g (f r 1) (m - 2) * g (f (n - r) 1) (m - 2)
let _ = Scanf.scanf "%d %d" @@ fun x y -> Printf.printf "%d\n" @@ if (x + y) mod 3 > 0 then 0 else c ((x + y) / 3) (y - (x + y) / 3)