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

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

  print((0))

elif x < 0 or y < 0:

  print((0))

elif x/y > 2 or y/x > 2:

  print((0))

else:

  n = (x+y) // 3

  m = x - n

  mod = 10**9 + 7

  def inv(x):

    y = 1

    while x != 1:

      y *= mod//x + 1

      y %= mod

      x -= mod%x

    return y

  #print(inv(5))

  ans = 1

  for i in range(m):

    ans *= (n-i)

    ans %= mod

    ans *= inv(m-i)

    ans %= mod

  #print(n,m)

  print(ans)
#17:23

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

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

  print((0))

elif x*2 < y or y*2 < x:

  print((0))

else:

  a = (x + y) // 3

  b = y - a

  mod = 10 ** 9 + 7

  def inv(x):

    y = 1

    while x != 1:

      y *= mod // x + 1

      y %= mod

      x -= mod % x

    return y

  ans = 1

  for i in range(b):

    ans *= a - i

    ans %= mod

    ans *= inv(b-i)

    ans %= mod

  print(ans)
x, y = list(map(int, input().split()))
if (x + y) % 3 != 0:
    print((0))
elif x < 0 or y < 0:
    print((0))
elif x / y > 2 or y / x > 2:
    print((0))
else:
    n = (x + y) // 3
    m = x - n
    mod = 10**9 + 7

    def inv(x):
        y = 1
        while x != 1:
            y *= mod // x + 1
            y %= mod
            x -= mod % x
        return y

    # print(inv(5))
    ans = 1
    for i in range(m):
        ans *= n - i
        ans %= mod
        ans *= inv(m - i)
        ans %= mod
    # print(n,m)
    print(ans)

# 17:23
x, y = list(map(int, input().split()))
if (x + y) % 3 != 0:
    print((0))
elif x * 2 < y or y * 2 < x:
    print((0))
else:
    a = (x + y) // 3
    b = y - a
    mod = 10**9 + 7

    def inv(x):
        y = 1
        while x != 1:
            y *= mod // x + 1
            y %= mod
            x -= mod % x
        return y

    ans = 1
    for i in range(b):
        ans *= a - i
        ans %= mod
        ans *= inv(b - i)
        ans %= mod
    print(ans)

+# 17:23 -elif x < 0 or y < 0: -    print((0)) -elif x / y > 2 or y / x > 2: +elif x * 2 < y or y * 2 < x: -    n = (x + y) // 3 -    m = x - n +    a = (x + y) // 3 +    b = y - a -    # print(inv(5)) -    for i in range(m): -        ans *= n - i +    for i in range(b): +        ans *= a - i -        ans *= inv(m - i) +        ans *= inv(b - i) -    # print(n,m)