using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using static System.Console;

public static class Program
{
    private static readonly long INF = long.MaxValue / 2;
    private static readonly int MOD = 1000000007;
        
        struct Pair<T, U> : IComparable<Pair<T, U>>
            where T : IComparable<T>
            where U : IComparable<U>
        {
            public T first;
            public U second;
            private bool CompWithFirst;
 
            public Pair(T f, U s, int comp)
            {
                first = f;
                second = s;
                CompWithFirst = comp == 1;
            }
 
            public int CompareTo(Pair<T, U> other)
            {
                return CompWithFirst ? first.CompareTo(other.first) : second.CompareTo(other.second);
            }
        }
        
     public class PriorityQueue<T> where T : IComparable<T>
    {
 
        private List<T> Q;
        private readonly int r;
 
        public PriorityQueue(bool ascending)
        {
            if (ascending)
            {
                r = 1;
            }
            else
            {
                r = -1;
            }
            Q = new List<T>();
        }
 
 
        private void PushHeap(List<T> list, T item)
        {
            int n = list.Count();
            list.Add(item);
 
            while (n != 0)
            {
                int pIndex = (n - 1) / 2;
 
                if (list[n].CompareTo(list[pIndex]) * r > 0)
                {
                    Swap(Q, n, pIndex);
                }
                else { break; }
 
                n = pIndex;
            }
        }
 
        private void PopHeap(List<T> list)
        {
            int n = list.Count() - 1;
            list[0] = list[n];
            list.RemoveAt(n);
 
            int cur = 0;
            int comp;
 
            while (2 * cur + 1 <= n - 1)
            {
                int c1 = 2 * cur + 1;
                int c2 = 2 * (cur + 1);
                if (c1 == n - 1)
                {
                    comp = c1;
                }
                else
                {
 
                    comp = list[c1].CompareTo(list[c2]) * r > 0 ? c1 : c2;
                }
 
                if (list[cur].CompareTo(list[comp]) * r < 0)
                {
                    Swap(Q, cur, comp);
                }
                else { break; }
 
                cur = comp;
            }
        }
 
        private void Swap(List<T> list, int a, int b)
        {
            T keep = list[a];
            list[a] = list[b];
            list[b] = keep;
        }
 
 
 
        public void Enqueue(T value)
        {
            PushHeap(Q, value);
        }
 
        public T Dequeue()
        {
            T ret = Q[0];
            PopHeap(Q);
            return ret;
        }
 
        public T Peek()
        {
            return Q[0];
        }
 
        public int CountItem()
        {
            return Q.Count();
        }
    }
     
     static long ModInv(long a, long m) {
         long b = m, u = 1, v = 0;
         while (b != 0) {
             long t = a / b;
             a -= t * b;
             long tmp = a;
             a = b;
             b = tmp;
             u -= t * v;
             tmp = u;
             u = v;
             v = tmp;
         }
         u %= m;
         if (u < 0) u += m;
         return u;
     }
        
     public static long CalcComb(long n, long m)
     {
         //nＣm ＝ nＣm-1 ×（n-m+1）/ m 
//         return CalcFact(n) / (CalcFact(m) * CalcFact(n - m));
         //MODで割ってbの逆元を求める
         return CalcFact(n) * ModInv((CalcFact(m) * CalcFact(n - m)) % MOD, MOD) % MOD;
     }

     /// <summary>
     /// 階乗を計算する。
     /// </summary>
     /// <param name="n">n</param>
     /// <returns>nの階乗（n!）</returns>
     public static long CalcFact(long n)
     {
         if (n <= 0) {
             return 1;
         }
        
         return n * CalcFact(n - 1) % MOD;
     }
     
        public static void Main(string[] args)
        {
            var input1 = ReadLine().Split(' ').Select(int.Parse).ToArray();
            int x = input1[0];
            int y = input1[1];

            if ((x + y) % 3 != 0)
            {
                WriteLine(0);
                return;
            }
            
            // n + 2m = x
            // 2n + m = y
            //なのでm = (2x-y)/3
            //     n = x-2m
            int n, m;
            m = (2 * x - y) / 3;
            n = x - 2 * m;
            if (n < 0 || m < 0) {
              WriteLine(0);
                return;
            } 

            //n+mCn
            long ans = CalcComb((n + m), n);
            WriteLine(ans);
        }
    }


Measured memory_bytes: 23764