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

def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

if (2*Y - X) < 0:
    print((0))
elif (2*X - Y) < 0:
    print((0))
else:
    if (X - 2*Y) % 3 != 0 or (2*X - Y) % 3 != 0:
        print((0))
    else:
        a = (2 * Y - X) // 3
        b = (2 * X - Y) // 3
        m = 10**9+7
        res = 1
        for i in range(1,a+b+1):
            res = res*i%m
        for i in range(1,a+1):
            res = res*mod_inv(i,m)%m
        for i in range(1,b+1):
            res = res*mod_inv(i,m)%m
        print(res)

# Optimized solution
X, Y = list(map(int, input().split()))
M = 1000000007

def cmb(n, r):
    if n - r < r:
        r = n - r
    if r == 0:
        return 1
    if r == 1:
        return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result


if (2*Y - X) < 0:
    print((0))
elif (2*X - Y) < 0:
    print((0))
else:
    if (X - 2*Y) % 3 != 0 or (2*X - Y) % 3 != 0:
        print((0))
    else:
        a = (2 * Y - X) // 3
        b = (2 * X - Y) // 3
        ans = cmb(a+b, a)
        ans = ans % M
        print(ans)
# Original solution
x, y = list(map(int, input().split()))
mod = 10**9 + 7
if (x + y) % 3 != 0:
    print((0))
    exit()
n = (x + y) // 3
a = (2 * y - x) // 3
b = (2 * x - y) // 3
if a == 0 or b == 0:
    print((1))
    exit()
if a < 0 or b < 0:
    print((0))
    exit()
MAX = 700000
fac = [1, 1] + [0] * MAX
finv = [1, 1] + [0] * MAX
inv = [0, 1] + [0] * MAX
for i in range(2, MAX):
    fac[i] = fac[i - 1] * i % mod
    inv[i] = -inv[mod % i] * (mod // i) % mod
    finv[i] = finv[i - 1] * inv[i] % mod


def nCr(n, r):
    if n < r:
        return 0
    if n < 0 or r < 0:
        return 0
    return fac[n] * (finv[r] * finv[n - r] % mod) % mod


print((nCr(n, a)))


# Optimized solution
x, y = list(map(int, input().split()))
mod = 10**9 + 7
if (x + y) % 3:
    print((0))
    exit()
n = (x + y) // 3
a = (2 * y - x) // 3
b = (2 * x - y) // 3
if a < 0 or b < 0:
    print((0))
    exit()
if a == 0 or b == 0:
    print((1))
    exit()


def neko(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


print((neko(n, a)))
# Original solution
x, y = list(map(int, input().split()))
mod = 10**9 + 7
if (x + y) % 3:
    print((0))
    exit()
n = (x + y) // 3
a = (2 * y - x) // 3
b = (2 * x - y) // 3
if a < 0 or b < 0:
    print((0))
    exit()
if a == 0 or b == 0:
    print((1))
    exit()


def neko(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


print((neko(n, a)))


# Optimized solution
x, y = list(map(int, input().split()))
mod = 10**9 + 7
if (x + y) % 3:
    print((0))
    exit()
n = (x + y) // 3
a = (2 * y - x) // 3
b = (2 * x - y) // 3
if a < 0 or b < 0:
    print((0))
    exit()
if a == 0 or b == 0:
    print((1))
    exit()


def neko(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i) % mod
        q = q * (i + 1) % mod
    return p * pow(q, mod - 2, mod) % mod


r = min(a, b)
print((neko(n, r)))
# Original solution
from functools import reduce
x, y = list(map(int, input().split()))
mod = pow(10,9)+7

min_value = min(x, y)
max_value = max(x, y)
#print(min_value, max_value)
dif_value = max_value - min_value
#print(dif_value)
a_value   = min_value - dif_value
a_num     = int(a_value*2*(1/3))
#print(a_value, a_num)
n = dif_value + a_num
r = int(a_num*0.5)
#print(n, r)

def nCr(n,r,DIV):
  if r<n-r:
    r=n-r
  if r==0:
    return 1
  f=lambda x,y:x*y%DIV
  X=reduce(f,list(range(n-r+1,n+1)))
  Y=reduce(f,list(range(1,r+1)))
  return X*pow(Y,DIV-2,DIV)%DIV

if a_value % 3 == 0:
    print((nCr(n, r, mod)))
else:
    print((0))

# Optimized solution
from functools import reduce
def nCr(n,r,DIV):
  if r<n-r:
    r=n-r
  if r==0:
    return 1
  f=lambda x,y:x*y%DIV
  X=reduce(f,list(range(n-r+1,n+1)))
  Y=reduce(f,list(range(1,r+1)))
  return X*pow(Y,DIV-2,DIV)%DIV

mod = pow(10, 9) + 7
x, y = list(map(int, input().split()))
left, right = 0, 0
a, b = max(x, y), min(x, y)

if (2*b - a) % 3 == 0:
    d, s = a - b, (2*b - a)//3
    p, q = d + s, s
    print((nCr(p+q, p, mod)))
else:
    print((0))
# Original solution
M = 10 ** 9 + 7

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

r = 0
if (x + y) % 3 == 0:
  a, b = (2 * y - x) // 3, (2 * x - y ) // 3
  if a >= 0 <= b:
    n = a + b + 1
    f = [1] * n
    for i in range(1, n):
      f[i] = f[i - 1] * i % M
    r = f[a + b] * pow(f[a] * f[b], M - 2, M) % M
print(r)


# Optimized solution
M = 10 ** 9 + 7

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

r = 0
if (x + y) % 3 == 0:
  a, b = (2 * y - x) // 3, (2 * x - y ) // 3
  if a >= 0 <= b:
    f = [1]
    for i in range(1, a + b + 1):
      f.append(f[-1] * i % M)
    r = f[a + b] * pow(f[a] * f[b], M - 2, M) % M
print(r)
# Original solution
M = 10 ** 9 + 7

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

r = 0
if (x + y) % 3 == 0:
  m = (x + y ) // 3
  a, b = (2 * y - x) // 3, (2 * x - y ) // 3
  if x >= m <= y:
    f = [1]
    for i in range(1, m + 1):
      f.append(f[-1] * i % M)
    r = f[m] * pow(f[a] * f[b], M - 2, M) % M
print(r)


# Optimized solution
M = 10 ** 9 + 7
 
x, y = list(map(int, input().split()))
 
r = 0
if (x + y) % 3 == 0:
  a, b = (2 * y - x) // 3, (2 * x - y ) // 3
  if a >= 0 <= b:
    f = [1]
    for i in range(1, a + b + 1):
      f.append(f[-1] * i % M)
    r = f[a + b] * pow(f[a] * f[b], M - 2, M) % M
print(r)
# Original solution
inf = 10**9+7
import sys
a = 0
def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result = (result * numerator[k])%inf
    return result

x, y = list(map(int, input().split()))
key = 0
if x == 2*y:
    print((1))
    sys.exit()
if y == 2*x:
    print((1))
    sys.exit()
while x>0 and y>0:
    x, y = x-3, y-3
    key += 1
    if x == 2*y:
        a = 1
        break
    if y == 2*x:
        a = -1
        break

if x < 0 or y < 0:
    print((0))
    sys.exit()

if a == 0:
    print((0))
elif a == 1:
    print((int(nCr(key*2+y ,key))))
else:
    print((int(nCr(key*2+x ,key))))

# Optimized solution
import sys

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

inf = 10**9+7

if (x+y)%3 != 0:
    print((0))
    sys.exit()
    
a = (2*x-y)//3
b = (2*y-x)//3

if a<0 or b<0:
    print((0))
    sys.exit()

def nCr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return int(n%inf);
    numerator = [n - r + i + 1 for i in range(r)]
    denominator  = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1: 
            result = (result*numerator[k])%inf
    return int(result)

print((nCr(a+b, a)))
# Original solution
x,y=list(map(int,input().split()))
if (x+y)%3!=0 : 
    print((0))
    exit()

a=(2*y-x)//3
b=(2*x-y)//3
if a<0 or b<0 :
    print((0))
    exit()

def C(n, r ,mod=10**9+7):
    if n-r<r: r=n-r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) %mod

    return result % mod

print((C(a+b,b)))



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

mod=10**9+7
def C(n, r ,mod=10**9+7):
    if n-r<r: r=n-r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k]) %mod

    return result % mod

a=(-x+2*y)/3
b=(2*x-y)/3
if a<0 or b<0 : print((0)) ; exit()
if a%1!=0 or b%1!=0:
    print((0)) 
    exit()
a=int(a) ; b=int(b)
print((C(a+b,a)))
# Original solution
import sys
import math
input = sys.stdin.readline
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 = 2*10**6+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 )


def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))

x,y=MI()
if y>2*x or x>2*y:
    print((0))
    sys.exit()
elif x%3==0 and y%3==0:
    m=x//3
    l=y//3
    print((cmb(m+l,2*l-m,mod)))
    
elif x%3==1 and y%3==2:
    m=(x-1)//3
    l=(y-2)//3
    print((cmb(m+l+1,2*l-m+1,mod)))
elif x%3==2 and y%3==1:
    m=(x-2)//3
    l=(y-1)//3
    print((cmb(m+l+1,2*l-m,mod)))
else:
    print((0))

# Optimized solution
import sys
import math
input = sys.stdin.readline
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 )


def I(): return int(eval(input()))
def MI(): return list(map(int, input().split()))
def LI(): return list(map(int, input().split()))

x,y=MI()
if y>2*x or x>2*y:
    print((0))
    sys.exit()
elif x%3==0 and y%3==0:
    m=x//3
    l=y//3
    print((cmb(m+l,2*l-m,mod)))
    
elif x%3==1 and y%3==2:
    m=(x-1)//3
    l=(y-2)//3
    print((cmb(m+l+1,2*l-m+1,mod)))
elif x%3==2 and y%3==1:
    m=(x-2)//3
    l=(y-1)//3
    print((cmb(m+l+1,2*l-m,mod)))
else:
    print((0))
# 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 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

def cinit(N):
    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()))
if (X+Y)%3==0and(X<Y*2 or Y<X*2):
    cinit((X+Y)//3)
    p = (min(X,Y)*2 - max(X,Y))//3
    print((cmb((X+Y)//3,p,mod)))
else:
    print((0))

# Optimized solution
mod = 10**9+7
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
def cinit(N):
    for i in range( 2, N + 1 ):
        g1[i] = ( ( g1[i-1] * i ) % mod )
        inverse[i] = ( ( -inverse[mod % i] * (mod//i) ) % mod )
        g2[i] = ( (g2[i-1] * inverse[i]) % mod )
X,Y = list(map(int, input().split()))
if (X+Y)%3==0and(X<Y*2 or Y<X*2):
    N = (X+Y)//3
    g1,g2,inverse = [0]*(N+1),[0]*(N+1),[0]*(N+1)
    g1[0],g1[1],g2[0],g2[1],inverse[0],inverse[1] = 1,1,1,1,0,1
    cinit(N)
    p = (min(X,Y)*2 - max(X,Y))//3
    print((cmb((X+Y)//3,p,mod)))
else:
    print((0))
# Original solution
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
X, Y = list(map(int, input().split()))
if X > Y:
    X, Y = Y, X
dist = X + Y
if dist % 3 != 0:
    print((0))
    quit()
n = int((2 * X - Y) / 3)
m = int((2 * Y - X) / 3)
if n < 0 or m < 0:
    print((0))
    quit()
mod = 10 ** 9 + 7
fac, ifac = make_tables(mod, n + m)
ans = cmb(n + m, m, mod, fac, ifac)
print(ans)

# Optimized solution
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod


def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)

    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
X, Y = list(map(int, input().split()))
dist = X + Y
if dist % 3 != 0:
    print((0))
    quit()
n = int((2 * X - Y) / 3)
m = int((2 * Y - X) / 3)
if n < 0 or m < 0:
    print((0))
    quit()
mod = 10 ** 9 + 7
fac, ifac = make_tables(mod, n + m)
ans = cmb(n + m, m, mod, fac, ifac)
print(ans)
# Original solution
X, Y = list(map(int, input().split()))
if (X + Y) % 3 != 0:
    print((0))
    quit()
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3
if n < 0 or m < 0:
    print((0))
    quit()
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

p = 10 ** 9 + 7
N = 10 ** 6  # N は必要分だけ用意する
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)
print((cmb(n + m, n, p)))

# Optimized solution
X, Y = list(map(int, input().split()))
def cmb(n, k, mod, fac, ifac):
    """
    nCkを計算する
    """
    k = min(k, n-k)
    return fac[n] * ifac[k] * ifac[n-k] % mod

def make_tables(mod, n):
    """
    階乗テーブル、逆元の階乗テーブルを作成する
    """
    fac = [1, 1] # 階乗テーブル・・・(1)
    ifac = [1, 1] #逆元の階乗テーブル・・・(2)
    inverse = [0, 1] #逆元テーブル・・・(3)
 
    for i in range(2, n+1):
        fac.append((fac[-1] * i) % mod)
        inverse.append((-inverse[mod % i] * (mod//i)) % mod)
        ifac.append((ifac[-1] * inverse[-1]) % mod)
    return fac, ifac
if (X + Y) % 3 != 0:
    print((0))
    quit()
n = (2 * Y - X) // 3
m = (2 * X - Y) // 3
if n < 0 or m < 0:
    print((0))
    quit()
mod = 10 ** 9 + 7
fac, ifac = make_tables(mod, n + m)
print((cmb(n + m, n, mod, fac, ifac)))
# Original solution
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))

def main():

    def fur(n,r):
        p,q = 1,1
        for i in range(r):
            p = p*(n-i)%mod
            q = q*(i+1)%mod
        return p * pow(q,mod-2,mod) % mod

    x, y = nm()

    if (x + y) % 3 != 0:
        print((0))
        exit()
    
    n = (2*y - x) // 3 # (X, Y) -> (X+1, Y+2) 
    m = (2*x - y) // 3 # (X, Y) -> (X+2, Y+1) 

    if n < 0 or m < 0:
        print((0))
        exit()

    print((fur(n+m, n)))

if __name__ == '__main__':
    main()

# Optimized solution
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: list(map(int, input().split()))
nl = lambda: list(map(int, input().split()))


def fur(n,r):
    p,q = 1,1
    for i in range(r):
        p = p*(n-i)%mod
        q = q*(i+1)%mod
    return p * pow(q,mod-2,mod) % mod

x, y = nm()

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

n = (2*y - x) // 3 # (X, Y) -> (X+1, Y+2) 
m = (2*x - y) // 3 # (X, Y) -> (X+2, Y+1) 

if n < 0 or m < 0:
    print((0))
    exit()

print((fur(n+m, n)))
# Original solution
X, Y = list(map(int, input().split()))
MOD = int(1e9 + 7)

def modinv(a, mod=MOD):
    return pow(a, mod-2, mod)

def combination(n, r, mod=MOD):
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

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

b = (2 * Y - X) // 3
a = X - Y + b

if a < 0 or b < 0:
    print((0))
    exit()


print((combination(a+b, a, MOD)))

# Optimized solution
# https://atcoder.jp/contests/abc145/tasks/abc145_d

X, Y = list(map(int, input().split()))
MOD = int(1e9 + 7)

def combination(n, r, mod=MOD):
    def modinv(a, mod=MOD):
        return pow(a, mod-2, mod)
    # nCr with MOD
    r = min(r, n - r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

# 1回の移動で3増えるので，X+Yは3の倍数 (0, 0) start
if (X + Y) % 3 != 0:
    ans = 0
    print((0))
else:
    # X+Yは3の倍数
    # (+1, +2)をn回，(+2, +1)をm回実行
    # n + 2m = X
    # 2n + m = Y
    # 3 m = 2 X - Y
    # m = (2 X - Y) // 3
    # n = X - 2 * m
    
    m = (2 * X - Y) // 3
    n = X - 2 * m

    if m < 0 or n < 0:
        print((0))
    else:
        print((combination(m + n, m, MOD)))
# Original solution
import sys
sys.setrecursionlimit(10**7)
import math

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

z = 10**9+7

X, Y = list(map(int, input().split()))
x = (-X+2*Y)/3
y = (2*X-Y)/3
if x.is_integer() and y.is_integer() and x>=0 and y>=0:
    x = int(x)
    y = int(y)
    maximam = max(x,y)
    minimam = min(x,y)
    print((cmb(x+y,minimam)%z))
else:
    print((0))

# Optimized solution
import sys
sys.setrecursionlimit(10**7)
import math

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()))
x = (-X+2*Y)/3
y = (2*X-Y)/3
if x.is_integer() and y.is_integer() and x>=0 and y>=0:
    x = int(x)
    y = int(y)
    maximam = max(x,y)
    minimam = min(x,y)
    mod = 10**9+7 #出力の制限
    N = x+y
    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(x+y,minimam,mod)))
else:
    print((0))
# Original solution
mod = int(1e9 + 7)
def powmod(a, b):
    ans = 1
    while(b):
        if(b&1): ans = ans*a%mod
        a = a*a%mod
        b >>= 1
    return ans
x, y = list(map(int,input().split()))
if(2*x < y or 2*y < x or (2*x-y)%3 or (2*y-x)%3): print((0))
else:
    x, y = (2*x-y)//3, (2*y-x)//3
    #print(x,y)
    fac = [0 for i in range(x+y+1)]
    inv = [0 for i in range(x+y+1)]
    fac[0] = 1
    for i in range(1,x+y+1):
        fac[i] = fac[i-1]*i%mod
    inv[x+y] = powmod(fac[x+y],mod-2)
    for i in range(x+y-1,-1,-1):
        inv[i] = inv[i+1]*(i+1)%mod
    ans = fac[x+y]*inv[x]*inv[y]%mod
    print(ans)

# Optimized solution
mod = int(1e9 + 7)
x, y = list(map(int,input().split()))
if(2*x < y or 2*y < x or (2*x-y)%3 or (2*y-x)%3): print((0))
else:
    x, y = (2*x-y)//3, (2*y-x)//3
    #print(x,y)
    fac = [0 for i in range(x+y+1)]
    fac[0] = 1
    for i in range(1,x+y+1):
        fac[i] = fac[i-1]*i%mod
    ans = fac[x+y]*pow(fac[x],mod-2,mod)*pow(fac[y],mod-2,mod)%mod
    print(ans)
# Original solution
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7

#modに対応して高速なコンビネーションが求められる
# 階乗 & 逆元計算

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

def combinations_count(n,r):
    if n-r < 0:
        return 0
    return factorial[n]*inverse[r]*inverse[n-r]%mod

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X,Y = LI()

if (X + Y) % 3 != 0:
    ans = 0
else:
    m = int(X * 2 / 3 - Y / 3)
    n = int(Y * 2 / 3 - X / 3)
    # print(m,n)
    ans = combinations_count(m + n, n)
print(ans)


# Optimized solution
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections

mod = 10**9+7

#modに対応して高速なコンビネーションが求められる
# 階乗 & 逆元計算



d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))

X,Y = LI()

if (X + Y) % 3 != 0:
    ans = 0
else:
    n = 10 ** 6
    factorial = [1]
    inverse = [1]
    for i in range(1, n+2):
        factorial.append(factorial[-1] * i % mod)
        inverse.append(pow(factorial[-1], mod-2, mod))

    def combinations_count(n,r):
        if n-r < 0:
            return 0
        return factorial[n]*inverse[r]*inverse[n-r]%mod
    m = int(X * 2 / 3 - Y / 3)
    n = int(Y * 2 / 3 - X / 3)
    if (X+Y) / 3 > X or (X + Y) / 3 > Y or m < 0 or n < 0:
        ans = 0
    else:
        ans = combinations_count((X + Y)//3, n)
print(ans)
# Original solution
x,y=list(map(int,input().split()))

if (2*x-y)%3!=0 or (2*x-y)<0:
  print((0))
  exit()
if (2*y-x)%3!=0 or (2*y-x)<0:
  print((0))
  exit()
p=int((2*x-y)/3)
q=int((2*y-x)/3)
M=2*(10**6)
Mod=10**9+7

fac=[0]*M
finv=[0]*M
inv=[0]*M

def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(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)%Mod

COMinit()
print((COM(p+q,p)))

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

if (2*x-y)%3!=0 or (2*x-y)<0:
  print((0))
  exit()
if (2*y-x)%3!=0 or (2*y-x)<0:
  print((0))
  exit()
p=int((2*x-y)/3)
q=int((2*y-x)/3)
M=p+q+2
Mod=10**9+7

fac=[0]*M
finv=[0]*M
inv=[0]*M

def COMinit():
  fac[0]=fac[1]=1
  finv[0]=finv[1]=1
  inv[1]=1
  for i in range(2,M):
    fac[i]=(fac[i-1]*i%Mod)%Mod
    inv[i]=Mod-inv[Mod%i]*(Mod//i) %Mod
    finv[i]=(finv[i-1]*inv[i]%Mod)%Mod
def COM(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)%Mod

COMinit()
print((COM(p+q,p)))