x,y=gets.split.map(&:to_i)
s=x+y
b=s/3
if s%3!=0||x<b||y<b
  puts 0
  exit
end
x-=b
y-=b
class Integer
  def combination(k)
    return 1 if k.zero?
    (self - k + 1..self).inject(:*) / k.factorial
  end
  def permutation(k)
    return 1 if k.zero?
    (self - k + 1..self).inject(:*)
  end
  def factorial
    return 1 if self.zero?
    (1..self).inject(:*)
  end
end
puts (x+y).combination(y)%1000000007
