x , y = gets.chomp.split(" ").map(&:to_i)
xy_amari = (x + y) % 3
xy = (x + y) / 3
x_new,y_new = [x - xy, y - xy].sort


all = x_new + y_new
arr = [*y_new..all]
aa = 1
arr.each do |i|
    aa = aa * i
    aa = aa % (10 ** 9 + 7)
end
arr_x = [*1..x_new]
ax = 1
arr_x.each do |i|
    ax = ax * i
end
if xy_amari == 0
puts (aa / ax ) % (10 ** 9 + 7)
else
    puts "0"
end