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

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

# n ->  +1, +2 の移動回数
# m ->  +2, +1 の移動回数

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

if n < 0 || m < 0
  p 0
  exit
end

def factorial(f,e)
  (f..e).inject(1) do |sum, a|
    (sum * a) % (10 ** 9 + 7)
  end
end

p ((factorial(m+1, n+m)) / (factorial(1,n))) % (10 ** 9 + 7)
