class Integer

  # O(min(n-k,k) log m)
  # combination: nPk / k! (mod p), note: m must be a prime number
  def cmb(k, m=10**9+7)
    n = self
    k = n - k if k > n - k
    n.prm(k, m) * k.prm(k,m).modinv(m) % m
  end

  # mod must be a prime number
  # O(log m)
  def modinv(mod = 10**9+7)
    pow(mod-2, mod)
  end

  # O(log n)
  def pow(n , mod = nil )
    a = self
    res = 1
    while n > 0
      if (n & 1) != 0
        res *= a
        res %= mod if mod
      end
      a *= a
      a %= mod if mod
      n >>= 1
    end
    res
  end

  # O(k)
  def prm(k, mod = nil)
    (0...k).reduce(1) do |res,i|
      res *= (self - i )
      res %= mod if mod
      res
    end
  end
end

x, y = gets.to_s.split.map{|t|t.to_i}

a =    2 * x -  y 
b =   - x + 2 * y 
 
ans = 0
if a % 3 == 0 and b % 3 == 0
  a = a / 3
  b = b / 3
  ans = (a+b).cmb(a)
end

print(ans)