mod=1000000007
def modinverse(a,m)
  b=m
  u=1
  v=0
  while b>0
    t=a/b
    a-=t*b
    u-=t*v
    a,b=b,a
    u,v=v,u
  end
  u%=m
  if u<0
    u+=m
  end
  return u
end
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
a=1
y.times do |i|
  a*=x+i+1
  a%=mod
  a*=modinverse(i+1,mod)
  a%=mod
end
puts a