mo=10^9+7
main=do
 [x,y]<-map read.words<$>getLine
 let n=div(2*y-x)3
 let m=div(2*x-y)3
 print$if mod(x+y)3==0 then c(n+m)n 1 1 else 0
c a 0 x y=x*(power y$mo-2)`mod`mo
c a b x y=c(a-1)(b-1)(x*a`mod`mo)(y*b`mod`mo)
power a n
 |n==0=1
 |n`mod`2==0=power(a*a`mod`mo)(div n 2)
 |True=a*(power a(n-1))`mod`mo