using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
using System.Threading;
using System.Threading.Tasks;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var X = cin.ReadInt;
            var Y = cin.ReadInt;
            if (2 * Y < X || Y > 2 * X || (X * 2 - Y) % 3 != 0 || (Y * 2 - X) % 3 != 0)
            {
                Console.WriteLine(0);
                return;
            }
            
            var X2 = (X * 2 - Y) / 3;
            var Y2 = (Y * 2 - X) / 3;
            var MOD = 1000000007L;

            // (X2+Y2)_C_X2
            var facts = new long[X2 + Y2 + 1];
            var invs = new long[X2 + Y2 + 1];
            facts[0] = 1;
            invs[0] = 1;
            for (var i = 1; i <= X2 + Y2; i++)
            {
                facts[i] = (facts[i - 1] * i) % MOD;
                invs[i] = ModInv(facts[i], MOD);
            }
            var ans = (((facts[X2 + Y2] * invs[X2]) % MOD) * invs[Y2]) % MOD;
            Console.WriteLine(ans);
        }

        // 返り値: a と b の最大公約数
        // ax + by = gcd(a, b) を満たす (x, y) が格納される
        static long ExtGcd(long a, long b, ref long x, ref long y)
        {
            if (b == 0)
            {
                x = 1;
                y = 0;
                return a;
            }
            long d = ExtGcd(b, a % b, ref y, ref x);
            y -= a / b * x;
            return d;
        }

        static long ModInv(long a, long mod)
        {
            long x = 0, y = 0;
            ExtGcd(a, mod, ref x, ref y);
            if (x < 0) x += mod; //modInv will never be negative
            return x;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }
}


Measured memory_bytes: 21472