x, y = gets.split.map &: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

fact = [1, 1]
finv = [1, 1]
2.upto(y) do |i|
  fact[i] = i * fact[i-1] % MOD
  finv[i] = mod_pow(fact[i], MOD-2, MOD)
end

cnt = 0

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

p cnt