import itertools

import math

import numpy as np

import fractions

from collections import deque

from itertools import combinations

from functools import reduce

from functools import lru_cache

import bisect

import sys

sys.setrecursionlimit(10**9)



def main():

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

    p = 10**9+7



    i = (2*X-Y)/3

    j = (2*Y-X)/3



    if i < 0 or j < 0 or not(i.is_integer() and j.is_integer()):

        print((0))

        exit()



    i = int(i)

    j = int(j)



    def comb(n, r, mod):

        r = min(r, n-r)

        res = 1

        for i in range(r):

            res = res * (n - i) * pow(i+1, mod-2, mod) % mod

        return res



    print((comb(i+j,i,p)))





if __name__ == "__main__":

  main()
import sys

sys.setrecursionlimit(10**9)



def mi(): return list(map(int,input().split()))

def ii(): return int(eval(input()))

def isp(): return input().split()

def deb(text): print(("-------\n{}\n-------".format(text)))



INF=10**20



class Counting():

    def __init__(self,maxim,mod):

        maxim += 1



        self.mod = mod

        self.fact = [0]*maxim

        self.fact[0] = 1

        for i in range(1,maxim):

            self.fact[i] = self.fact[i-1] * i % mod



        self.invfact = [0]*maxim

        self.invfact[maxim-1] = pow(self.fact[maxim-1],mod-2,mod)

        for i in reversed(list(range(maxim-1))):

            self.invfact[i] = self.invfact[i+1] * (i+1) % mod

        





    def nCk(self,n,r):

        if n < 0 or n < r: return 0

        return self.fact[n] * self.invfact[r] * self.invfact[n-r] % self.mod



    def nPk(self,n,r):

        if n < 0 or n < r: return 0

        return self.fact[n] * self.invfact[n-r] % self.mod



        

def main():

    X,Y=mi()

    MOD = 10**9+7

    C = Counting(10**6+10,MOD)

    ans = 0

    for a in range(X+1):

        if (X-a) %2 == 1: continue

        b = (X-a)//2



        if 2*a+b == Y:

            ans += C.nCk(a+b,a)

    

    print(ans)













if __name__ == "__main__":

    main()
import itertools
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
import bisect
import sys

sys.setrecursionlimit(10**9)


def main():
    X, Y = list(map(int, input().split()))
    p = 10**9 + 7
    i = (2 * X - Y) / 3
    j = (2 * Y - X) / 3
    if i < 0 or j < 0 or not (i.is_integer() and j.is_integer()):
        print((0))
        exit()
    i = int(i)
    j = int(j)

    def comb(n, r, mod):
        r = min(r, n - r)
        res = 1
        for i in range(r):
            res = res * (n - i) * pow(i + 1, mod - 2, mod) % mod
        return res

    print((comb(i + j, i, p)))


if __name__ == "__main__":
    main()

import sys

sys.setrecursionlimit(10**9)


def mi():
    return list(map(int, input().split()))


def ii():
    return int(eval(input()))


def isp():
    return input().split()


def deb(text):
    print(("-------\n{}\n-------".format(text)))


INF = 10**20


class Counting:
    def __init__(self, maxim, mod):
        maxim += 1
        self.mod = mod
        self.fact = [0] * maxim
        self.fact[0] = 1
        for i in range(1, maxim):
            self.fact[i] = self.fact[i - 1] * i % mod
        self.invfact = [0] * maxim
        self.invfact[maxim - 1] = pow(self.fact[maxim - 1], mod - 2, mod)
        for i in reversed(list(range(maxim - 1))):
            self.invfact[i] = self.invfact[i + 1] * (i + 1) % mod

    def nCk(self, n, r):
        if n < 0 or n < r:
            return 0
        return self.fact[n] * self.invfact[r] * self.invfact[n - r] % self.mod

    def nPk(self, n, r):
        if n < 0 or n < r:
            return 0
        return self.fact[n] * self.invfact[n - r] % self.mod


def main():
    X, Y = mi()
    MOD = 10**9 + 7
    C = Counting(10**6 + 10, MOD)
    ans = 0
    for a in range(X + 1):
        if (X - a) % 2 == 1:
            continue
        b = (X - a) // 2
        if 2 * a + b == Y:
            ans += C.nCk(a + b, a)
    print(ans)


if __name__ == "__main__":
    main()

-import itertools -import math -import numpy as np -import fractions -from collections import deque -from itertools import combinations -from functools import reduce -from functools import lru_cache -import bisect +def mi(): +    return list(map(int, input().split())) + + +def ii(): +    return int(eval(input())) + + +def isp(): +    return input().split() + + +def deb(text): + + +INF = 10**20 + + +class Counting: +    def __init__(self, maxim, mod): +        maxim += 1 +        self.mod = mod +        self.fact = [0] * maxim +        self.fact[0] = 1 +        for i in range(1, maxim): +            self.fact[i] = self.fact[i - 1] * i % mod +        self.invfact = [0] * maxim +        self.invfact[maxim - 1] = pow(self.fact[maxim - 1], mod - 2, mod) +        for i in reversed(list(range(maxim - 1))): +            self.invfact[i] = self.invfact[i + 1] * (i + 1) % mod + +    def nCk(self, n, r): +        if n < 0 or n < r: +            return 0 +        return self.fact[n] * self.invfact[r] * self.invfact[n - r] % self.mod + +    def nPk(self, n, r): +        if n < 0 or n < r: +            return 0 +        return self.fact[n] * self.invfact[n - r] % self.mod + + -    X, Y = list(map(int, input().split())) -    p = 10**9 + 7 -    i = (2 * X - Y) / 3 -    j = (2 * Y - X) / 3 -    if i < 0 or j < 0 or not (i.is_integer() and j.is_integer()): -        print((0)) -        exit() -    i = int(i) -    j = int(j) - -    def comb(n, r, mod): -        r = min(r, n - r) -        res = 1 -        for i in range(r): -            res = res * (n - i) * pow(i + 1, mod - 2, mod) % mod -        return res - -    print((comb(i + j, i, p))) +    X, Y = mi() +    MOD = 10**9 + 7 +    C = Counting(10**6 + 10, MOD) +    ans = 0 +    for a in range(X + 1): +        if (X - a) % 2 == 1: +            continue +        b = (X - a) // 2 +        if 2 * a + b == Y: +            ans += C.nCk(a + b, a) +    print(ans)