q=(10**9)+7
def com(n,k)
   k = [k, n-k].min

   if k==0
      val = 1
   else
      val = com(n-1,k-1)*n/k
   end

   return val
end




x,y=gets.chomp.split(" ").map{|s| s.to_i}
if (x+y)%3!=0
  p 0
  exit
end

u=[x,y].max
v=[x,y].min
c=0
while u!=v
  u-=2
  v-=1
  c+=1
end
p=u/3
a=[]
a[0]=1

p com(c+p*2,p)%q