from operator import mul
from functools import reduce
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
X,Y=[int(x) for x in input().split()]
a = X%3
b = Y%3
mod = 10**9+7
if a==b==0:
  if X==Y:
    c = X//3
    #print(c)
    N = c*2
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    for i in range( 2, N + 1 ):
      g1.append( ( g1[-1] * i ) % mod )
      inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
      g2.append( (g2[-1] * inverse[-1]) % mod )
    print(cmb(c*2,c,mod))
  else:
    if X>Y:
      l = X-Y
      d = (Y-l)//3
      N = l+d*2
      g1 = [1, 1] # 元テーブル
      g2 = [1, 1] #逆元テーブル
      inverse = [0, 1] #逆元テーブル計算用テーブル
      for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
      print(cmb(l+d*2,d,mod))
    else:
      l = Y-X
      d = (X-l)//3
      N = l+d*2
      g1 = [1, 1] # 元テーブル
      g2 = [1, 1] #逆元テーブル
      inverse = [0, 1] #逆元テーブル計算用テーブル
      for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
      print(cmb(l+d*2,d,mod))
elif a==2 and b==1:
  x =X-2
  y =Y-1
  if x==y:
    c = x//3
    N = c*2+1
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    for i in range( 2, N + 1 ):
      g1.append( ( g1[-1] * i ) % mod )
      inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
      g2.append( (g2[-1] * inverse[-1]) % mod )
    print(cmb(c*2+1,c,mod))
  else:
    if x>y:
      l = x-y
      d = (y-l)//3
      N = l+d*2+1
      g1 = [1, 1] # 元テーブル
      g2 = [1, 1] #逆元テーブル
      inverse = [0, 1] #逆元テーブル計算用テーブル
      for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
      print(cmb(l+d*2+1,d,mod))
    else:
      l = y-x
      d = (x-l)//3
      N = l+d*2+1
      g1 = [1, 1] # 元テーブル
      g2 = [1, 1] #逆元テーブル
      inverse = [0, 1] #逆元テーブル計算用テーブル
      for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
      print(cmb(l+d*2+1,d+1,mod))
elif a==1 and b==2:
  x =X-1
  y =Y-2
  if x==y:
    c = x//3
    N = c*2+1
    g1 = [1, 1] # 元テーブル
    g2 = [1, 1] #逆元テーブル
    inverse = [0, 1] #逆元テーブル計算用テーブル
    for i in range( 2, N + 1 ):
      g1.append( ( g1[-1] * i ) % mod )
      inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
      g2.append( (g2[-1] * inverse[-1]) % mod )
    print(cmb(c*2+1,c,mod))
  else:
    if x>y:
      l = x-y
      d = (y-l)//3
      N = l+d*2+1
      g1 = [1, 1] # 元テーブル
      g2 = [1, 1] #逆元テーブル
      inverse = [0, 1] #逆元テーブル計算用テーブル
      for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
      print(cmb(l+d*2+1,d+1,mod))
    else:
      l = y-x
      d = (x-l)//3
      N = l+d*2+1
      g1 = [1, 1] # 元テーブル
      g2 = [1, 1] #逆元テーブル
      inverse = [0, 1] #逆元テーブル計算用テーブル
      for i in range( 2, N + 1 ):
        g1.append( ( g1[-1] * i ) % mod )
        inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2.append( (g2[-1] * inverse[-1]) % mod )
      print(cmb(l+d*2+1,d,mod))
else:
  print(0)

Measured memory_bytes: 83092