//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <stdlib.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define INF (ll) 1000000007

long long modp(long long a, long long p) {
    long long res = a % p;
    if (res < 0) res += p;
    return res;
}

long long extEuclid(long long a, long long b, long long *x, long long *y){
    if (b == 0) {
        *x = 1;
        *y = 0;
        return a;
    }
    long long d = extEuclid(b, a%b, y, x);
    *y -= a/b * *x;
    return d;
}

long long myModinv(long long a, long long p){
    long long x, y;
    extEuclid(a, p, &x, &y);
    return modp(x,p);
}

long long modinv(long long a, long long p){
    // a^{-1} = 1/a mod p (拡張Euclidの互除法)
    long long b = p, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= p;
    if (u < 0) u += p;
    return u;
}

long long mul_modp(long long a, long long b, long long p){
    // a*b mod p
    return ((a % p) * (b % p)) % p;
}

long long div_modp(long long a, long long b, long long p){
    // a/b mod p
    return mul_modp(a, modinv(b, p), p);
}

long long nCr_modp(long long n, long long r, long long p){

    if(n < r || n < 0 || r < 0) return 0;

    long long denominator = 1; // 分母
    long long numerator = 1; // 分子
    for(int i=0; i<r; i++){
        numerator = mul_modp(numerator, n-i, p);
        denominator = mul_modp(denominator, r-i, p); 
    }

    return div_modp(numerator, denominator, p);
}

int main() {

    ll X, Y;
    cin >> X >> Y;

    if((2*X-Y)%3 != 0 || (2*Y-X)%3 != 0 || (2*X-Y)<0 || (2*Y-X)<0){
        cout << 0 << endl;
        return 0;
    }

    ll x = (2*X-Y) / 3;
    ll y = (2*Y-X) / 3;

    cout << nCr_modp(x+y, y, INF) << endl;

    return 0;
}

Measured memory_bytes: 256