using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        class modMCalc
        {
            private const int M = 1000000007;       // 素数(int範囲)

            // 乗算結果 % Mを求める
            static public int Mul(int a, int b)
            {
                return (int)(Math.BigMul(a, b) % M);
            }

            // 冪乗(mod M)
            static public int Pow(int a, int m)
            {
                if (0 == m)
                {
                    return 1;
                }
                if (1 == m)
                {
                    return a;
                }

                int result = 1;
                int param = a;
                for (; m > 0; m >>= 1)
                {
                    if ((m & 0x01) == 1)
                    {
                        result = Mul(result, param);
                    }

                    param = Mul(param, param);
                }

                return result;
            }

            // 除算(mod M)
            static public int Div(int a, int b)
            {
                return Mul(a, Pow(b, M - 2));
            }
        }

        class CombinationPermutation
        {
            private readonly int[] fac;

            // コンストラクタ
            // (mod Mの)階乗テーブル作成する
            public CombinationPermutation(int n)
            {
                fac = new int[n + 1];
                fac[0] = 1;
                for (int i = 1; i <= n; ++i)
                {
                    fac[i] = modMCalc.Mul(fac[i - 1], i);
                }
            }

            // 階乗求める
            public int Factorial(int n)
            {
                return fac[n];
            }

            // nPr
            public int nPr(int n, int r)
            {
                if (n < r)
                {
                    return 0;
                }

                if (n == r)
                {
                    return 1;
                }

                int result = Factorial(n);
                result = modMCalc.Div(result, Factorial(n - r));

                return result;
            }

            // nCr
            public int nCr(int n, int r)
            {
                return modMCalc.Div(nPr(n, r), Factorial(r));
            }
        }


        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int X = int.Parse(s[0]);
            int Y = int.Parse(s[1]);

            if( 0 != ((X+Y) % 3))
            {
                Console.WriteLine(0);
                return;
            }

            if (X > Y * 2 || Y > X * 2)
            {
                Console.WriteLine(0);
                return;
            }

            if(X<Y)
            {
                int t = Y;
                Y = X;
                X = t;
            }

            int total = (X + Y) / 3;
            int ont = (2 * Y - X) / 3;

            CombinationPermutation p = new CombinationPermutation(total);

            int ans = p.nCr(total, ont);
            Console.WriteLine(ans);

            return;
        }
    }
}



Measured memory_bytes: 13536