x,y = gets.chomp.split.collect{ |item| item.to_i}


modi = 1000000007
result = 0
add = x+y
sub = -1
base = add/3

min = base*2 + 1
if x>y
  sub = x - 2*y
  oneA = min - x
else
  sub = y - 2*x
  oneA = min - y
end


def combi(n,k)
  return 0 if k < 0 || n < k
  return 1 if k == 0
  bunsi = 1
  bunbo = 1
  kk = ((n-k) < k) ? n-k : k
  kk.times do |ki|
    bunsi *= (n-ki)
    bunsi = bunsi / (ki+1)
  end
  return bunsi
end


if (add%3 ==0) && (sub <= 0)
  oneA -=1
  ans = combi(base,oneA)
  puts ans % modi

else
  puts 0
end
