MOD = 10**9 + 7

class Combination
  def initialize
    @fact = (1..10**6).to_a
    @fact.each_with_index do |e, idx|
      @fact[idx] = @fact[idx] * @fact[idx-1] % MOD if idx > 0
    end
  end

  def choose(n, r)
    return 0 if not (0 <= r and r <= n)
    return 1 if r == 0 or r == n
    fact(n) * inverse( fact(r) * fact(n-r) % MOD ) % MOD
  end

  def fact(n)
    @fact[n-1]
  end

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

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

lines = $stdin.read
array = lines.split("\n")
X,Y = array[0].split(" ").map(&:to_i)

if (X+Y)%3!=0
  puts 0
  exit 0
end

# 2*n + 4*m = 2*X
# 2*n + m = Y
# 3*m = 2*X - Y
# n = (Y-m)/2
m = (2*X - Y) / 3
n = (Y-m)/2

if m<0 or n<0
  puts 0
  exit 0
end

comb = Combination.new
puts comb.choose(m+n,n)