require 'openssl'

X, Y = gets.split.map(&:to_i)

MOD = OpenSSL::BN.new(1000000007)

def factorial(n)
  return 1 if n.zero?
  ret = (1..n).inject{|result, index|
    result = (result * index) % MOD
  }
  OpenSSL::BN.new(ret)
end

def able_to?(x, y)
  return true if x % 3 == 1 && y % 3 == 2
  return true if x % 3 == 2 && y % 3 == 1
  return true if x % 3 == 0 && y % 3 == 0
  return false
end

if able_to?(X, Y) then
  step_x = OpenSSL::BN.new(X / 2)
  step_y = OpenSSL::BN.new((Y - step_x) / 2)

  fac_xy = factorial(step_x + step_y)
  fac_x = factorial(step_x)
  fac_y = factorial(step_y)

  ans = ((fac_xy * (fac_x).mod_inverse(MOD)) % MOD) * (fac_y).mod_inverse(MOD) % MOD
else
  ans = 0
end

puts ans
