    x = gets.to_i
    y = gets.to_i

    # i + 2j = x and 2i + j = y
    # 3i + 3j = x + y
    # i + j = (x + y) / 3
    # i = (2i + j) - (i + j) = y - (x + y) / 3 = (-x + 2y) / 3
    a = (2 * y) - x
    b = (2 * x) - y
    
    #iとjは正の整数

    def kaijo(a, b, mod)
      result = 1
      ([a,b].min...[a,b].max).each {|v| result = (result * v) % mod}
      return result % mod
    end

    def joho_gyakugen(a, b, mod)
      #modを法とする逆元を計算
      result = 1
      ([a,b].min...[a,b].max).each {|v| result = (result * v) % mod}
      return ruijo(result, mod-2, mod)
    end
    
    def ruijo(i, bekisu, mod)
      result = i
      while bekisu > 1
        if bekisu % 2 == 0
          result = (result * result) % mod
          bekisu /= 2
        else
          result = (i * result) % mod
          bekisu -= 1
        end
      end
      return result % mod
    end
    
    if a < 0 or b < 0 or a % 3 != 0 or b % 3 != 0
      puts 0
    else
      n = [a, b].min / 3
      m = [a, b].max / 3
      total = n + m
      mod = (10 ** 9) + 7
      result = (kaijo(m+1, total, mod) * joho_gyakugen(1, n, mod)) % mod
      puts result
    end