class Modulo
  attr_accessor :num, :mod

  def initialize(mod, init = 0)
    @mod = mod
    @num = init % @mod
    @com_init_max = 0
  end

  def mod_inv(num)
    num2 = @mod
    u = 1
    v = 0
    while num2 > 0
      t = num / num2
      num, num2 = num2, num - t * num2
      u, v = v, u - t * v
    end
    u % @mod
  end

  def +(other)
    @num = (@num + other) % @mod
    self
  end

  def -(other)
    @num = (@num - other) % @mod
    self
  end

  def *(other)
    @num = (@num * other) % @mod
    self
  end

  def /(other)
    @num = (@num * mod_inv(other)) % @mod
    self
  end

  def **(other)
    ret = 1
    multi = @num
    other.to_s(2).chars.reverse.each do |b|
      ret = (ret * multi) % @mod if b == '1'
      multi = (multi**2) % @mod
    end
    @num = ret
    self
  end

  def com(n, k, max = nil)
    max = n if max.nil?
    com_init(max) if @com_init_max < max
    return 0 if n < k
    return 0 if n < 0 || k < 0
    @fac[n] * (@finv[k] * @finv[n - k] % @mod) % @mod
  end

  def to_s
    @num.to_s
  end

  def to_i
    @num.to_i
  end

  private

  def com_init(max)
    @com_init_max = max
    @fac = [0] * (max + 1)
    @finv = [0] * (max + 1)
    inv = [0] * (max + 1)
    @fac[0] = 1
    @fac[1] = 1
    @finv[0] = 1
    @finv[1] = 1
    inv[1] = 1;
    2.upto(max) do |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
    end
  end
end

def get(x, y)
  go21 = 0
  while x >= 0
    return [go21, x] if y == x * 2
    go21 += 1
    x -= 2
    y -= 1
  end
  nil
  

end


X, Y = gets.chomp.split.map(&:to_i)
a = get(X, Y)
if a.nil?
  puts "0"
  exit
end

mod = Modulo.new(10**9 + 7)
puts mod.com(a[0] + a[1], a[0])
