require 'matrix'
def imod a, b
	rev = b < a
	a, b = b, a if rev
	d = []
	until a == 0
		d << b/a
		a, b = b%a, a 
	end
	return nil if b != 1

	m = Matrix[
		[0,    1],
		[1,d.pop]
	]
	until d.empty?
		m *= Matrix[
			[0,    1],
			[1,d.pop]
		]
	end
	return rev ? m.row(0).to_a : m.row(0).to_a.reverse
end

X, Y = gets.split.map(&:to_i)
MOD = 1000000007
(p 0; exit) unless (X+Y)%3 == 0
L, R = [Y-(X+Y)/3, 2*(X+Y)/3-Y].minmax
(p 0; exit) if L < 0
p((R+1..L+R).inject(1){|s,n| s*n%MOD } * imod((1..L).inject(1){|s,d| s*d%MOD },MOD)[0] % MOD)
