let p = 1000000007

let pow a b =
  let rec f a b ret =
    if b = 0 then ret
    else if b mod 2 = 0 then f (a * a mod p) (b / 2) ret
    else f (a * a mod p) (b / 2) (ret * a mod p)
  in f a b 1

let mul s e =
  let rec f i ret =
    if i <= e then
      f (i+1) (ret * i mod p)
    else
      ret
  in f s 1

let fact n = mul 1 n

let nCr n r = mul (n-r+1) n * pow (fact r) (p-2) mod p

let ans x y =
  let sum = x + y in
  if sum mod 3 != 0 then 0
  else
    let m = (2*x-y)/3
    and n = (-x+2*y)/3
    in
    if n < 0 || m < 0 then 0
    else nCr (n+m) n
;;
Scanf.scanf "%d %d" (fun x y -> print_int (ans x y))
