@fact = [1]
def fact(n, mod)
  if n > @fact.size then
    f = @fact[-1]
    (@fact.size+1..n).each{|i|
      f = (f * i) % mod
      @fact << f
    }
  end
  @fact[n-1]
end

def inverse(x, mod)
  pow(x, mod-2, mod)
end

def pow(x, n, mod)
  ans = 1
  while n > 0
    ans = ans * x % mod if n.odd?
    x = x * x % mod
    n >>= 1
  end
  ans
end

X, Y = gets.chomp.split(" ").map(&:to_i)
MOD = 10 ** 9 + 7

xc = (X - 2 * Y) % -3
yc = (-2 * X + Y) % -3

if xc != 0 || yc != 0 then
  ans = 0
else
  x = (X - 2 * Y) / -3
  y = (-2 * X + Y) / -3
  if 0 > x || 0 > y then
    ans = 0
  elsif x == 0 || y == 0 then
    ans = 1
  else
    ans = fact(x + y, MOD) * inverse(fact(x, MOD) * fact(y, MOD) % MOD, MOD) % MOD
  end
end

puts ans
