$mod = 10 ** 9 + 7

def fac(n, m)
    (n..m).inject(1) {|r, v| r * v % $mod}
end

def power(x, n)
    n == 0 ? 1 : ((n.odd? ? x : 1) * power(x ** 2 % $mod, n / 2) % $mod)
end

def com(n, m)
    m = n - m if n < 2 * m
    fac(n - m + 1, n) * power(fac(1, m), $mod - 2) % $mod
end

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

a, ma = (2 * y - x).divmod(3)
b, mb = (2 * x - y).divmod(3)

puts ma != 0 || mb != 0 ? 0 : com(a + b, a)