MOD = 10 ** 9 + 7
ONE = '1'.freeze

def nCk(n, k)
  return 0 if n < k
  (fact(k + 1, n) * inv(fact(1, n - k) % MOD)) % MOD
end

def fact(s, e)
  (s..e).inject(1) { |r, i| (r * i) % MOD }
end

def inv(x)
  res = 1
  beki = x
  (MOD - 2).to_s(2).reverse.chars do |digest|
    res = (beki * res) % MOD if digest == ONE
    beki = (beki * beki) % MOD
  end
  res
end

def puts_0
  puts 0
  exit
end

x, y = gets.split.map(&:to_i)
count, mod = (x + y).divmod(3)
puts_0 if mod > 0
right_count = x - count
up_count = y - count
puts_0 if right_count < 0 || up_count < 0
puts nCk(count, right_count)
