MOD = 1000000007

def fact(n)
  (1..n).inject(1){ |ans,x| ans*x % MOD }
end

def pow(n, k)
  ans = 1
  while k > 0
    ans = ans*n % MOD if k.odd?
    n = n*n % MOD
    k >>= 1
  end
  ans
end

def comb(n, k)
  fact(n) * pow(fact(n-k),MOD-2) % MOD * pow(fact(k),MOD-2) % MOD
end

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

sum = x+y
if sum%3 != 0
  puts(0)
  exit
end

x -= sum/3
y -= sum/3

puts(comb(x+y, x))