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

  def comb(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


X,Y = gets.split.map(&:to_i)

if (2 * Y - X) % 3 == 0 && (2 * X - Y) % 3 == 0
  a = (2 * Y - X) / 3
  b = (2 * X - Y) / 3
  puts Combination.new.comb(a + b, a)
else
  puts 0
end
