require 'prime'
class NCK_mod
  def initialize(mod)
    raise "incompatible error" unless mod.prime?
    @MOD = mod
    @fac = [1,1]
    @finv = [1,1]
    @inv = [0,1]
    @n = 1
  end

  def prepare(n)
    return if @n >= n
    (@n+1..n).each{|i|
      @fac[i] = @fac[i - 1] * i % @MOD;
      @inv[i] = @MOD - @inv[@MOD%i] * (@MOD / i) % @MOD;
      @finv[i] = @finv[i - 1] * @inv[i] % @MOD;
    }
    @n = n
  end

  def calc(n,k)
    raise "range error" if n < 0 || k < 0
    raise "incompatible error" if n >= @MOD
    return 0 if n < k
    prepare(n)
    return @fac[n] * (@finv[k] * @finv[n - k] % @MOD) % @MOD;
  end
end

x,y=gets.split.map(&:to_i)

if (x+y)%3!=0
  p 0
  exit
end

k = [(2*x-y)/3,(2*y-x)/3].min
n = (x+y)/3
nCk = NCK_mod.new(1000000007)

p nCk.calc(n,k)
