import math

a,b=list(map(int,input().split()))

x=max(a,b)

y=min(a,b)

p=abs(x-y)



P = 10**9 + 7

N = 1000000

inv_t = [0]+[1]

for i in range(2,N):

  inv_t += [inv_t[P % i] * (P - int(P / i)) % P]



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

    print((0))

elif x>y*2:

    print((0))

else:

    n=(x+y)//3

    q=(2*x-y)//3

    r=(2*y-x)//3

    

    #print(math.factorial(q+r)//math.factorial(q)//math.factorial(r)%(10**9+7))

    ans=1

    qq=1

    rr=1

    for i in range(1,q+r+1):

        ans*=i

        ans%=10**9+7

    for i in range(1,q+1):

        ans*=inv_t[i]

        ans%=10**9+7



    P = 10**9 + 7

    N = r+2

    inv_t = [0]+[1]

    for i in range(2,N):

        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]



    for i in range(1,r+1):

        ans*=inv_t[i]

        ans%=10**9+7

            

            

    print(ans)

import math

a,b=list(map(int,input().split()))

x=max(a,b)

y=min(a,b)

p=abs(x-y)



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

    print((0))

elif x>y*2:

    print((0))

else:

    n=(x+y)//3

    q=(2*x-y)//3

    r=(2*y-x)//3

    

    #print(math.factorial(q+r)//math.factorial(q)//math.factorial(r)%(10**9+7))

    ans=1

    qq=1

    rr=1

    P = 10**9 + 7

    N = max(q,r)+2

    inv_t = [0]+[1]

    for i in range(2,N):

        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]

    for i in range(1,q+r+1):

        ans*=i

        ans%=10**9+7

    for i in range(1,q+1):

        ans*=inv_t[i]

        ans%=10**9+7

    for i in range(1,r+1):

        ans*=inv_t[i]

        ans%=10**9+7

            

            

    print(ans)

import math

a, b = list(map(int, input().split()))
x = max(a, b)
y = min(a, b)
p = abs(x - y)
P = 10**9 + 7
N = 1000000
inv_t = [0] + [1]
for i in range(2, N):
    inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
if (x + y) % 3 != 0:
    print((0))
elif x > y * 2:
    print((0))
else:
    n = (x + y) // 3
    q = (2 * x - y) // 3
    r = (2 * y - x) // 3
    # print(math.factorial(q+r)//math.factorial(q)//math.factorial(r)%(10**9+7))
    ans = 1
    qq = 1
    rr = 1
    for i in range(1, q + r + 1):
        ans *= i
        ans %= 10**9 + 7
    for i in range(1, q + 1):
        ans *= inv_t[i]
        ans %= 10**9 + 7
    P = 10**9 + 7
    N = r + 2
    inv_t = [0] + [1]
    for i in range(2, N):
        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
    for i in range(1, r + 1):
        ans *= inv_t[i]
        ans %= 10**9 + 7
    print(ans)

import math

a, b = list(map(int, input().split()))
x = max(a, b)
y = min(a, b)
p = abs(x - y)
if (x + y) % 3 != 0:
    print((0))
elif x > y * 2:
    print((0))
else:
    n = (x + y) // 3
    q = (2 * x - y) // 3
    r = (2 * y - x) // 3
    # print(math.factorial(q+r)//math.factorial(q)//math.factorial(r)%(10**9+7))
    ans = 1
    qq = 1
    rr = 1
    P = 10**9 + 7
    N = max(q, r) + 2
    inv_t = [0] + [1]
    for i in range(2, N):
        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]
    for i in range(1, q + r + 1):
        ans *= i
        ans %= 10**9 + 7
    for i in range(1, q + 1):
        ans *= inv_t[i]
        ans %= 10**9 + 7
    for i in range(1, r + 1):
        ans *= inv_t[i]
        ans %= 10**9 + 7
    print(ans)

-P = 10**9 + 7 -N = 1000000 -inv_t = [0] + [1] -for i in range(2, N): -    inv_t += [inv_t[P % i] * (P - int(P / i)) % P] +    P = 10**9 + 7 +    N = max(q, r) + 2 +    inv_t = [0] + [1] +    for i in range(2, N): +        inv_t += [inv_t[P % i] * (P - int(P / i)) % P] -    P = 10**9 + 7 -    N = r + 2 -    inv_t = [0] + [1] -    for i in range(2, N): -        inv_t += [inv_t[P % i] * (P - int(P / i)) % P]