#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()

#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()

# 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()

# 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()

- - -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 -    print(com(n, m, mod)) +    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)