CodeEff/ECCO huggingface dataset:
# Original solution
x, y = list(map(int, input().split()))

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


mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル

if (x+y) % 3 != 0:
    ans = 0

else:
    a = (x + y)//3
    b = x-a

    if x-a <0 or y-a <0:
        ans = 0
    else:
        mod = 10**9+7 #出力の制限
        N = a+b
        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 )

        ans = cmb(a, b, mod)

print((int(ans)))


# Optimized solution
x, y = list(map(int, input().split()))

def cmb(n, r, mod):
    from operator import mul
    from functools import reduce

    N = n + r
    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)

    if (r<0 or r>n):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod


if (x+y) % 3 != 0:
    ans = 0

else:
    a = (x + y)//3
    b = x-a

    if x-a <0 or y-a <0:
        ans = 0
    else:
        mod = 10**9+7 #出力の制限
        ans = cmb(a, b, mod)

print((int(ans)))
# Original solution
def make_tables(m):
    fac=[1,1]
    finv=[1,1]
    inv=[0,1]
    for i in range(2,m+1):
        fac.append((fac[-1]*i)%mod)
        inv.append((-inv[mod%i]*(mod//i))%mod)
        finv.append(finv[i-1]*inv[i]%mod)
    return fac,finv

def calc_nCk(n,k,fac,finv):
    if n<k or (n<0 or k<0):
        return 0
#    k=min(k,n-k)
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod

x,y=list(map(int,input().split()))
mod=10**9+7
n=(y-0.5*x)/1.5
if int(n)!=n:
    print((0))
else:
    m=(y+x)//3
    l=int(n)
    fac,finv=make_tables(m)
    ans = calc_nCk(m,l,fac,finv)
    print(ans)

# Optimized solution
def nCk(n,k):
    if n<k or (n<0 or k<0):
        return 0
    #k=min(k,n-k)
    num,denum=1,1
    for i in range(k):
        num=num*(n-i)%mod
        denum=denum*(i+1)%mod
    return num*pow(denum,mod-2,mod)%mod

x,y=list(map(int,input().split()))
mod=10**9+7
n=(y-0.5*x)/1.5
if int(n)!=n:
    print((0))
else:
    m=(y+x)//3
    l=int(n)
    print((nCk(m,l)))
# Original solution
#!/usr/bin/env python3
from functools import reduce

x, y = list(map(int, input().split()))

mod = 10**9 + 7


def cmb(n, r, m):
    def mul(a, b):
        return a * b % m

    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, list(range(n, n - r, -1)))
    under = reduce(mul, list(range(1, r + 1)))
    return (over * pow(under, m - 2, m))%m


r = abs(x - y)
l = (min(x, y) - r) // 3
r += l
if l*2+r*1 in (x,y) and l >= 0:
    print((cmb(r + l, l, mod)))
else:
    print((0))


# Optimized solution
#!/usr/bin/env python3
from functools import reduce

x, y = list(map(int, input().split()))

mod = 10**9 + 7


def cmb(n, r, m):
    def mul(a, b):
        return a * b % m

    r = min(n - r, r)
    if r == 0:
        return 1
    over = reduce(mul, list(range(n, n - r, -1)))
    under = reduce(mul, list(range(1, r + 1)))
    return (over * pow(under, m - 2, m))%m


r = abs(x - y)
l = (min(x, y) - r) // 3
r += l
if (x+y)%3 < 1 and l >= 0:
    print((cmb(r + l, l, mod)))
else:
    print((0))
# Original solution
LARGE = 10 ** 9 + 7


def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    z = (x + y) // 3
    if x < z or y < z:
        return 0
    # zC(x-z)
    r = min(x - z, y - z)
    res = 1
    for i in range(r):
        res *= z - i
        res *= pow(i + 1, LARGE - 2, LARGE)
        res %= LARGE
    return res


def main():
    x, y = list(map(int, input().split()))
    res = solve(x, y)
    print(res)


def test():
    assert solve(3, 3) == 2
    assert solve(2, 2) == 0
    assert solve(999999, 999999) == 151840682


if __name__ == "__main__":
    test()
    main()


# Optimized solution
LARGE = 10 ** 9 + 7


def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    z = (x + y) // 3
    if x < z or y < z:
        return 0
    # zC(x-z)
    r = min(x - z, y - z)
    res = 1
    for i in range(r):
        res *= z - i
        res *= pow(i + 1, LARGE - 2, LARGE)
        res %= LARGE
    return res


def main():
    x, y = list(map(int, input().split()))
    res = solve(x, y)
    print(res)


def test():
    assert solve(3, 3) == 2
    assert solve(2, 2) == 0
    assert solve(999999, 999999) == 151840682


if __name__ == "__main__":
    # test()
    main()
# Original solution
x,y = list(map(int,input().split()))
if (x+y) % 3 != 0:
  print((0))
elif x < 0 or y < 0:
  print((0))
elif x/y > 2 or y/x > 2:
  print((0))
else:
  n = (x+y) // 3
  m = x - n
  mod = 10**9 + 7
  def inv(x):
    y = 1
    while x != 1:
      y *= mod//x + 1
      y %= mod
      x -= mod%x
    return y
  #print(inv(5))
  ans = 1
  for i in range(m):
    ans *= (n-i)
    ans %= mod
    ans *= inv(m-i)
    ans %= mod
  #print(n,m)
  print(ans)

# Optimized solution
#17:23
x,y = list(map(int,input().split()))
if (x+y) % 3 != 0:
  print((0))
elif x*2 < y or y*2 < x:
  print((0))
else:
  a = (x + y) // 3
  b = y - a
  mod = 10 ** 9 + 7
  def inv(x):
    y = 1
    while x != 1:
      y *= mod // x + 1
      y %= mod
      x -= mod % x
    return y
  ans = 1
  for i in range(b):
    ans *= a - i
    ans %= mod
    ans *= inv(b-i)
    ans %= mod
  print(ans)
# Original solution
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

N = 10**6     #出力の制限
mod = 10**9+7 
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 )

X ,Y = list(map(int, input().split()))
n = 2 * Y - X
m = 2 * X - Y
r = 1
if n % 3 != 0:
    r = 0
elif m % 3 != 0:
    r = 0
else:
    r = cmb(n//3+m//3,n//3,mod)
print(r)

# Optimized solution
mod = 10 ** 9 + 7  # mod素数
def nCr(n, r, mod):
  ret = [1]*(r+1)
  for i in range(1, r+1):
    ret[i] = (ret[i-1] * (n-i+1) * pow(i,mod-2,mod)) % mod
  return ret
    
X,Y=list(map(int,input().split()))
x,y = 2*X-Y, 2*Y-X
if x<0 or y<0 or x%3!=0 or y%3!=0:
  ret=0
else:
  x,y=x//3,y//3
  nCrl = nCr(x+y, min(x,y), mod)
  ret=nCrl[min(x,y)]
print(ret)
# Original solution
#coding:utf-8
import bisect
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True


def com(a, b, p):
    if a < b or a < 0 or b < 0:
        return 0
    fac = [1]*(a+1)
    inv = [1]*(a+1)
    finv = [1]*(a+1)

    for i in range(2, a+1):
        fac[i] = fac[i-1] * i % p
        inv[i] = p - (inv[p%i] * (p//i) )% p
        finv[i] = finv[i-1] * inv[i] % p

    return fac[a] * (finv[b] * finv[a - b] % p) % p


def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    x, y = LMIIS()

    if (x+y)%3!=0:
      print(0)
      exit()
    n = (x+y)//3
    if 0 > x-n or 0 > y-n:
      print(0)
      exit()

    m = min(x-n,y-n)
    mod = 10**9 + 7

    print(com(n, m, mod))


if __name__ == '__main__':
    main()


# Optimized solution
#coding:utf-8
import bisect
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True



def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    x, y = LMIIS()

    if (x+y)%3!=0:
      print(0)
      exit()
    n = (x+y)//3
    if 0 > x-n or 0 > y-n:
      print(0)
      exit()

    m = min(x-n,y-n)
    mod = 10**9 + 7

    a = 1
    b = 1
    for i in range(n - m + 1, n+1):
        a = a * i % mod
    for i in range(1, m + 1):
        b = b * i % mod
    print(a * pow(b, mod - 2, mod) % mod)




if __name__ == '__main__':
    main()
# Original solution
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 = list(map(int,input().split()))

mod = 10**9+7

division = (x+y)//3

if (x+y)%3!=0:
    print((0))
    exit()


mod = 10**9+7

#combを求める前処理 O(log division)
g1 = [1, 1] #元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

for i in range( 2, division + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( pow(i,mod-2,mod) )
    g2.append( (g2[-1] * inverse[-1]) % mod )

r = min(x,y)-division
ans = cmb(division,r,mod)

print(ans)

# Optimized solution
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 = list(map(int,input().split()))

if (x+y)%3!=0:
    print((0))
    exit()


mod = 10**9+7
division = (x+y)//3

#combを求める前処理（階乗とその逆数）

g1 = [1, 1] #元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
for i in range( 2, division + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

#################################

r = min(x,y)-division
ans = cmb(division,r,mod)

print(ans)
# Original solution
MOD=10**9+7
x , y = list(map(int, input().split()))
a=(2*x-y)//3
b=(2*y-x)//3
if 2*a+b!=x:
    print((0))
    exit()

factorial = [1]
inverse = [1]

n=a+b
r=a

for i in range(1, n+2):
    factorial.append(factorial[-1] * i % MOD)
    inverse.append(pow(factorial[-1], MOD - 2, MOD))

def combi(n, r):
    if n < r or r < 0:
        return 0
    elif r == 0:
        return 1
    return factorial[n] * inverse[r] * inverse[n - r] % MOD

ans = combi(n,r)
print(ans)


# Optimized solution
N=10**9+7
x , y = list(map(int, input().split()))
a=(2*x-y)//3
b=(2*y-x)//3

if 2*a+b!=x:
    print((0))
    exit()

n=a+b
r=a

def fac(n,r,N):
    ans=1
    for i in range(r):
        ans=ans*(n-i)%N
    return ans

def combi(n,r,N):
    if n<r or n<0 or r<0:
        ans = 0
        return ans
    r= min(r, n-r)
    ans = fac(n,r,N)*pow(fac(r,r,N),N-2,N)%N
    return ans

ans = combi(n,r,N)
print(ans)
# Original solution
def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    n = (x + y) // 3
    r = min((2 * y - x) // 3, (2 * x - y) // 3)
    return cmb(n, r, mod)

_x, _y = list(map(int, input().split()))

mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, _x + _y + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((- inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

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

print((solve(_x, _y)))


# Optimized solution
def solve(x, y):
    if (x + y) % 3 != 0:
        return 0
    n = (x + y) // 3
    r = min((2 * y - x) // 3, (2 * x - y) // 3)
    return cmb(n, r, mod)

_x, _y = list(map(int, input().split()))

mod = 10 ** 9 + 7
g1 = [1, 1] # 元テーブル
g2 = [1, 1] # 逆元テーブル
inverse = [0, 1] # 逆元テーブル計算用テーブル

for i in range(2, max(_x, _y) + 1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((- inverse[mod % i] * (mod // i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

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

print((solve(_x, _y)))
# Original solution
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


MOD = 10**9 + 7

X, Y = read_ints()
if (X + Y) % 3 != 0:  # !=0
    print((0))
    exit()

pascal_depth = int((X + Y) / 3)  # パスカルの三角形に当たるn
x, y = int((X + Y) * 2 / 3), (X + Y) / 3
pascal_k = x - X  # 端からいくつずれているか

if pascal_k > pascal_depth / 2:
    pascal_k = pascal_depth - pascal_k


def cmb(n, r, mod):
    if (r < 0 or r > n):
        return 0
    r = min(r, n - r)
    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)
    return g1[n] * g2[r] * g2[n - r] % mod


a = cmb(pascal_depth, pascal_k, MOD)
print(a)


# Optimized solution
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


MOD = 10**9 + 7

X, Y = read_ints()
if (X + Y) % 3 != 0 or Y / X > 2 or Y / X < 1 / 2:  # !=0
    print((0))
    exit()

pascal_depth = int((X + Y) / 3)  # パスカルの三角形に当たるn
x = ((X + Y) * 2) // 3
pascal_k = x - X  # 端からいくつずれているか


def combination(n, r, mod=MOD):
    r = min(r, n - r)
    nf = rf = 1
    for i in range(r):
        nf = nf * (n - i) % mod
        rf = rf * (i + 1) % mod
    return nf * pow(rf, mod - 2, mod) % mod


# def com(n, k, mod):
#     if k == 0:
#         return 1
#     s = n
#     mod = 10**9 + 7
#     inv = [0, 1]
#     for c in range(2, k + 1):
#         inv.append((-(mod // c) * inv[mod % c]) % mod)
#         s = (((s * (n + 1 - c)) % mod) * inv[c]) % mod
#     return s


a = combination(pascal_depth, pascal_k, MOD)
print(a)
# Original solution
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

mod = 10**9+7 #出力の制限
N = 10**6
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 )

x, y = list(map(int, input().split()))

n = (x+y)/3
a = (-x+2*y)/3

#print(n)
#print(a)

if not n.is_integer() or not a.is_integer():
  print((0))
else:
  n = int(n)
  a = int(a)
  ans = cmb(n,a,mod)
  print(ans)
  
  

# Optimized solution
def cmb1(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

mod = 10**9+7 #出力の制限
N = 10**6+10
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 )


x, y = list(map(int, input().split()))
mod = 10**9+7

if (-x+2*y)>= 0 and (-x+2*y)%3 == 0 and  (2*x-y)>= 0 and (2*x-y)%3 == 0:
    a = (-x+2*y)//3
    b = (2*x-y)//3
    print((cmb1(a+b, a, mod)))
else:
    print((0))
# Original solution
MOD=10**9+7

def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  elif p%2==0:
    powsq=powmod(a,p//2)
    return (powsq**2)%MOD
  elif p%2==1:
    powsq=powmod(a,p//2)
    return (a*powsq**2)%MOD

def invmod(a):
  return powmod(a,MOD-2)

X,Y=list(map(int,input().split()))

if (X+Y)%3!=0:
  print((0))
else:
  u=(2*X-Y)//3
  v=(-X+2*Y)//3
  if u>=0 and v>=0:
    #print(int(u),int(v))
    ui=int(u)
    vi=int(v)

    bunshi=1
    for i in range(vi):
      bunshi*=ui+vi-i
      bunshi%=MOD
    bumbo=1
    for i in range(vi):
      bumbo*=vi-i
      bumbo%=MOD

    #calculate bunshi/bumbo%MOD as bunshi*bumbo^-1%MOD
    print((bunshi*invmod(bumbo)%MOD))
  else:
    print((0))

# Optimized solution
MOD=10**9+7
X,Y=list(map(int,input().split()))

def powmod(a,p):
  if p==0:
    return 1
  elif p==1:
    return a
  else:
    pow2=powmod(a,p//2)
    if p%2==0:
      return (pow2**2)%MOD
    else:
      return (a*pow2**2)%MOD
def invmod(a):
  return powmod(a,MOD-2)
def comb_mod(n,r):
  nPr=1
  fact_r=1
  for i in range(r):
    nPr*=n-i
    nPr%=MOD
    fact_r*=r-i
    fact_r%=MOD  
  return (nPr*invmod(fact_r))%MOD

if (X+Y)%3!=0:
  print((0))
else:
  u=(2*X-Y)//3
  v=(-X+2*Y)//3
  if u>=0 and v>=0:    
    #print(u,v)
    print((comb_mod(u+v,v)))
  else:
    print((0))
# Original solution
from functools import reduce

def modpow(a, m):
    ret = 1
    while m > 0:
        if m & 1:
            ret = ret * a % mod
        a = a * a % mod
        m = m >> 1
    return ret

def modinv(a):
    return modpow(a, mod - 2)

def cmb(n, r):
    r = min(r, n - r)
    if r == 0:
        return 1
    over = reduce(lambda a, b: a * b % mod, list(range(n, n - r, -1)))
    under = reduce(lambda a, b: a * b % mod, list(range(1, r + 1)))
    return over * modinv(under) % mod

x, y = [int(i) for i in input().split()]
if (x + y) % 3 or x > 2 * y or y > 2 * x:
    print((0))
else:
    mod = 10**9 + 7
    print((cmb((x + y) // 3, (2 * x - y) // 3)))


# Optimized solution
from functools import reduce

def cmb(n, r):
    r = min(r, n - r)
    if r == 0:
        return 1
    over = reduce(lambda a, b: a * b % mod, list(range(n, n - r, -1)))
    under = reduce(lambda a, b: a * b % mod, list(range(1, r + 1)))
    return over * pow(under, mod-2, mod) % mod

x, y = [int(i) for i in input().split()]
if (x + y) % 3 or x > 2 * y or y > 2 * x:
    print((0))
else:
    mod = 10**9 + 7
    print((cmb((x + y) // 3, (2 * x - y) // 3)))
# Original solution
def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7,r<=10**6 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


x, y = list(map(int, input().split()))
mod = 10**9+7

if (x + y) % 3 != 0 or x > 2 * y or 2 * x < y:
    print((0))
else:
    print((bigcmb((x + y) // 3, x - (x + y) // 3, mod)))


# Optimized solution
def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7,r<=10**6 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


x, y = list(map(int, input().split()))
mod = 10 ** 9 + 7

if (x + y) % 3 != 0 or (x > 2 * y) or (2 * x < y):
    print((0))
else:
    cnt = (x + y) // 3
    print((bigcmb(cnt, x - cnt, mod)))
# Original solution
def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7,r<=10**6 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


x, y = list(map(int, input().split()))
mod = 10 ** 9 + 7

if (x + y) % 3 != 0 or (x > 2 * y) or (2 * x < y):
    print((0))
else:
    cnt = (x + y) // 3
    print((bigcmb(cnt, x - cnt, mod)))


# Optimized solution
def bigcmb(N, R, MOD):  # nCr(mod p) #n>=10**7,r<=10**6 #前処理不要
    if (R < 0) or (N < R):
        return 0
    R = min(R, N - R)
    fact, inv = 1, 1
    for i in range(1, R + 1):
        fact = (fact * (N - i + 1)) % MOD
        inv = (inv * i) % MOD
    return fact * pow(inv, MOD - 2, MOD) % MOD


x, y = list(map(int, input().split()))
mod = 10 ** 9 + 7

if (x + y) % 3 != 0:
    print((0))
else:
    cnt = (x + y) // 3
    print((bigcmb(cnt, x - cnt, mod)))
# Original solution
MAX_NUM = 10**6 + 1
MOD = 10**9+7

fac  = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv  = [0 for _ in range(MAX_NUM)]

fac[0] = 1
fac[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1

for i in range(2,MAX_NUM):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def combinations(n,k):
    if (n < k):
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

X,Y = list(map(int,input().split()))

if (-Y + 2*X) % 3 == 0 and (2*Y - X) %3 == 0:
    x = (-Y + 2*X) // 3
    y = (2*Y - X) // 3
    
    result = combinations(x+y,min(x,y))
    print((int(result % MOD)))
    
else:
    print((0))
    


# Optimized solution
MAX_NUM = 10**6 + 1
MOD = 10**9+7

fac  = [0 for _ in range(MAX_NUM)]
finv = [0 for _ in range(MAX_NUM)]
inv  = [0 for _ in range(MAX_NUM)]

fac[0] = 1
fac[1] = 1
finv[0] = 1
finv[1] = 1
inv[1] = 1

for i in range(2,MAX_NUM):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def combinations(n,k):
    if (n < k):
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD

X,Y = list(map(int,input().split()))

if (-Y + 2*X) % 3 != 0 or (2*Y - X) %3 != 0 or (-Y + 2*X) < 0 or (2*Y - X) <0:
    print((0))
else:
    x = (-Y + 2*X) // 3
    y = (2*Y - X) // 3
    
    result = combinations(x+y,min(x,y))
    print((int(result % MOD)))
# Original solution
#ABC145D

MOD = 10 ** 9 + 7
import math
x,y = list(map(int,input().split()))
a,b = -1,-1

for i in range(x+1):
    m = 0
    if (x-i) % 2 == 0:
        m = (x-i) // 2
        if 2*i + m == y:
            if i >= 0 and m >= 0:
                a = i
                b = m
                break
    else:
        continue
        
MAX_N = 10**6

fact = [1]
fact_inv = [0]*(MAX_N+4)
for i in range(MAX_N+3):
    fact.append(fact[-1]*(i+1)%MOD)

fact_inv[-1] = pow(fact[-1],MOD-2,MOD)
for i in range(MAX_N+2,-1,-1):
    fact_inv[i] = fact_inv[i+1]*(i+1)%MOD

def com(n,k,mod):
    return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod  
        
        
if a == -1 and b == -1:
    print((0))
else:
    print((com(a+b,a,MOD)))

# Optimized solution
#ABC145D

MOD = 10 ** 9 + 7
import math
x,y = list(map(int,input().split()))
a,b = -1,-1

for i in range(x+1):
    m = 0
    if (x-i) % 2 == 0:
        m = (x-i) // 2
        if 2*i + m == y:
            if i >= 0 and m >= 0:
                a = i
                b = m
                break
    else:
        continue
        
def kai(x):
    an = 1
    for i in range(1,x+1):
        an = an * i % MOD
        
    return an

def pow_k(x, n):
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K = K * x % MOD
        x = x ** 2 % MOD
        n //= 2

    return K * x % MOD

al = kai(a)
be = kai(b)

if a == -1 and b == -1:
    print((0))
else:
    print((( kai(a+b) * pow_k(al,MOD-2)) % MOD * pow_k(be,MOD-2) % MOD ))