X,Y = gets.split.map &:to_i
MOD = 10 ** 9 + 7

def modinv(a,m)
  b,u,v = m,1,0
  while b > 0
    t = a / b
    a -= t * b; a,b = b,a
    u -= t * v; u,v = v,u
  end
  u %= m
end

def modfact(n,m)
  ans = 1
  (1..n).each do |i|
    ans *= i
    ans %= m
  end
  ans
end

T = (Y * 2 - X) / 3
S = (X * 2 - Y) / 3

if (X + Y) % 3 != 0 || T < 0 || S < 0 
  puts 0
  exit
end

a = modfact(S+T,MOD)
bb = modfact(S,MOD)
b = modinv(bb,MOD)
cc = modfact(T,MOD)
c = modinv(cc,MOD)

d = a * b % MOD
e = d * c % MOD

puts e
