x, y = gets.split.map &:to_i

remain = 0
diff = (x-y).abs
MOD = 10 ** 9 + 7

if x >= y then
	remain = y - (x - y)
else
	remain = x - (y - x)
end

if remain % 3 == 0 then
	ss = remain / 3
	ll = ss + (x-y).abs
	
	sum = 1
	
	(ss + 1 .. (ss+ll)).each{ |i|
		sum = sum * i % MOD
	}

	arr = (MOD-2).to_s(2).split("").reverse

	a = 1

	(1..ll).each{ |i|
		a = a * i % MOD
	}

	div = 1

	arr.each{ |i|
		if i == "1" then
			div = div * a % MOD
		end
		a = a * a % MOD
	}

	sum = sum * div % MOD

	puts sum
else
	puts 0
end