
    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は正の整数
    
    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
      y,z = 1
      joyo = (10 ** 9) + 7
      puts ((m+1...total).each{|v| y *= v} / (1...n).each{|v| z *= v}) % joyo
    end