X,Y = gets.split.map &:to_i
A3 = 2*X - Y
B3 = 2*Y - X
unless A3 >= 0 && B3 >= 0 && A3 % 3 == 0 && B3 % 3 == 0
  p 0; exit
end

A = A3 / 3; B = A3 / 3;

Mod = 10**9+7

def powmod(b,r,mod)
  a = 1
  while r > 0
    if r%2 == 1
      a = a * b % mod
    end
    b = b * b % mod
    r /= 2
  end
  a
end

def invmod(f, mod)
  powmod(f, mod-2, mod)
end

def factorial(n, mod)
  fs = [1]
  (1..n).each{ |k| fs << (fs[-1] * k) % mod }
  fs
end

$fs = factorial(A+B,Mod)

def comb(n,r)
  return 0 if r < 0
  return 0 if n < r
  $fs[n] * invmod($fs[r],Mod) % Mod * invmod($fs[n-r],Mod) % Mod
end

p comb(A+B, A)