using System;
using System.Collections.Generic;
using System.Linq;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3 3");
//2
}
else if (InputPattern == "Input2") {
WillReturn.Add("2 2");
//0
}
else if (InputPattern == "Input3") {
WillReturn.Add("999999 999999");
//151840682
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
const long Hou = 1000000007;
static void Main()
{
List<string> InputList = GetInputList();
long[] wkArr = InputList[0].Split(' ').Select(pX => long.Parse(pX)).ToArray();
long X = wkArr[0];
long Y = wkArr[1];
Console.WriteLine(Solve(X, Y));
}
static long Solve(long pX, long pY)
{
// 3の倍数であることが、移動可能な必要条件
if ((pX + pY) % 3 > 0) return 0;
// 連立方程式
// 2A + B = pX
// A + 2B = pY
// を解く
long B3 = 2 * pY - pX;
if (B3 % 3 > 0) return 0;
long B = B3 / 3;
if (B < 0) return 0;
long A = pY - 2 * B;
if (A < 0) return 0;
return DeriveCombi(A + B, A);
}
// nCr mod 法 を求める
static long DeriveCombi(long pN, long pR)
{
pR = Math.Min(pR, pN - pR);
long WillReturn = 1;
for (long I = pN; pN - pR < I; I--) {
WillReturn *= I;
WillReturn %= Hou;
}
for (long I = 2; I <= pR; I++) {
WillReturn *= DeriveGyakugen(I);
WillReturn %= Hou;
}
return WillReturn;
}
//引数の逆元を求める
static long DeriveGyakugen(long pLong)
{
return DeriveBekijyou(pLong, Hou - 2, Hou);
}
//繰り返し2乗法で、(NのP乗) Mod Mを求める
static long DeriveBekijyou(long pN, long pP, long pM)
{
long CurrJyousuu = pN % pM;
long CurrShisuu = 1;
long WillReturn = 1;
while (true) {
//対象ビットが立っている場合
if ((pP & CurrShisuu) > 0) {
WillReturn = (WillReturn * CurrJyousuu) % pM;
}
CurrShisuu *= 2;
if (CurrShisuu > pP) return WillReturn;
CurrJyousuu = (CurrJyousuu * CurrJyousuu) % pM;
}
}
}