MOD = 10**9 + 7

def fact(n)
  @facts ||= [1]
  (@facts.size).upto(n){|i| @facts << @facts[-1]*i % MOD}
  return @facts[n]
end

def modpow(x,n)
  ret = 1
  while n > 0
    ret = ret*x % MOD if n&1 == 1
    x = x*x % MOD
    n >>= 1
  end
  return ret
end

def modinv(x)
  return modpow(x,MOD-2)
end

def combin(n,k)
  return fact(n) * modinv(fact(n-k)) * modinv(fact(k)) % MOD
end

x,y = gets.split.map(&:to_i)
a,b = 0,0
while x < y * 2
  x -= 1
  y -= 2
  a += 1
end
if y * 2 != x
  p 0
else
  p combin(a+y,a)
end