let m_1e9 = int_of_float 1e9 + 7
let ( +^ ) x y = (x + y) mod m_1e9
let ( -^ ) x y = x - y + if x < y then m_1e9 else 0
let ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9

let rec mod_pow x n =
  if n = 0 then 1
  else let t = mod_pow x (n / 2) in t *^ t *^ if n mod 2 = 0 then 1 else x

let nPr n r = Array.(init r ((-) n) |> fold_left ( *^ ) 1)

let nCr n r = nPr n r *^ mod_pow (nPr r r) (m_1e9 - 2)

let (x, y) = Scanf.sscanf (read_line ()) "%d %d" @@ fun x y -> (x, y)

let () =
  if (x + y) mod 3 <> 0 then print_endline "0"
  else
    let x, y = min x y, max x y in
    let n = (2 * y - x) / 3 in
    let m = (x - n) / 2 in
    Printf.printf "%d\n" @@ if n < 0 || m < 0 then 0 else (nCr (n + m) n)