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

@memo = {}
def c(x, y)
  return 0 if x < 0 || y < 0
  return 0 if (x + y) % 3 != 0
  return 0 if (x > 2*y) || (y > 2*x)
  return 1 if (x == 2*y) || (y == 2*x)
  if @memo["#{x}:#{y}"]
    @memo["#{x}:#{y}"]
  else
    @memo["#{x}:#{y}"] = (c(x-2, y-1) + c(x-1, y-2)) % (10**9 + 7)
    @memo["#{y}:#{x}"] = @memo["#{x}:#{y}"]
    @memo["#{x}:#{y}"]
  end
end

p c(X, Y) % (10**9 + 7)
