MOD = 10**9 + 7
xx, yy = gets.split.map(&:to_i)

x = [xx, yy].min
y = [xx, yy].max

if x * 2 < y || (x+y) % 3 != 0
    puts 0
    exit
end

h = (x+y) / 3

a = Array.new(2).map{Array.new(h+2, 0)}
a[0][0] = 1
for i in 0..h
    cur = i % 2
    nex = (i+1) % 2
    a[nex].fill(0)
    for j in 0..i
        a[nex][j]   += a[cur][j]
        a[nex][j+1] += a[cur][j]
        a[nex][j]   %= MOD
        a[nex][j+1] %= MOD
    end
end

puts a[h%2][x-h]