def fact(n);(1..n).inject(1){|r,a|r*a}end
X, Y = gets.chomp.split(" ").map(&:to_i)
m = (2*Y - X)%3==0 ? (2*Y - X)/3 : nil 
n = (2*X - Y)%3==0 ? (2*X - Y)/3 : nil
if m && n
  puts (fact(m+n)/(fact(m)*fact(n))) % (10**9 + 7)
else
  puts 0
end