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



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

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

-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))) +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 -if __name__ == "__main__": -    main() +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)))