MOD = (10 ** 9) + 7
ONE = '1'.freeze

def nCr(n, k)
	(fact(n) * inv((fact(k) * fact(n-k)) %MOD))%MOD
end

def fact(a)
	(1..a).reduce(1) { |r, i| (r * i) % MOD }
end

def inv(x)
	g = 1
	beki = x
	(MOD - 2).to_s(2).reverse.chars do |digest|
		g = (beki * g)%MOD if digest == ONE
		beki = (beki * beki)%MOD
	end
	g
end

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

min, max = [x, y].sort

# min,maxのdiff回多く片方の遷移をしている。
diff = max - min
d_min = min - diff
d_max = max - 2 * diff
if !(d_min == d_max && d_min % 3 == 0)
	puts 0
else
	a = b = d_min / 3
	a += diff
	puts nCr(a + b, b)
end

