x, y = gets.to_s.split.map { |s| s.to_i }
MOD = 1_000_000_007

def mod_pow(a, e, p)
  r = 1
  while e > 0
    r = r * a % p if (e & 1) == 1
    a = a * a % p
    e >>= 1
  end
  r
end

len = [y, 2*y-x].max
fact = [1, 1]
invt = [1, 1]
finv = [1, 1]
2.upto(len) do |i|
  fact[i] = i * fact[i-1] % MOD
  invt[i] = MOD - invt[MOD % i] * (MOD / i) % MOD
  finv[i] = finv[i-1] * invt[i] % MOD
end

cnt = 0

(0..2*y-x).each do |b|
  a = y-b*2
  next unless a >= 0 && a*2+b == x && a+b*2 == y
  
  cnt += fact[a+b] * finv[a] % MOD * finv[b] % MOD
end

p cnt % MOD
