#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
int extgcd(int a, int b, int &x, int &y) {
    int g = a;
    x = 1, y = 0;
    if(b) {
        g = extgcd(b, a % b, y, x);
        y -= a / b * x;
    }
    return g;
}

// MOD逆元
int invmod(int a, int m = MOD){
    int x = 0, y = 0;
    extgcd(a, m, x, y);
    return (x + m) % m;
}
struct modint{
    int _num;
    modint(int x = 0) : _num(){
        _num = x % MOD;
        if(_num < 0) _num += MOD;
    }
    inline modint operator =  (int x) {
        _num = x % MOD;
        if(_num < 0) _num += MOD;
        return *this;
    }
    inline modint operator =  (modint x) {
        _num = x._num;
        return *this;
    }
    inline modint operator +  (int x) {return modint(_num + x);}
    inline modint operator +  (modint x) {
        int a = _num + x._num;
        if(a >= MOD) a -= MOD;
        return modint{a};
    }
    inline modint operator += (int x) {
        _num += x, _num %= MOD;
        if(_num < 0) _num += MOD;
        return *this;
    }
    inline modint operator += (modint x) {
        _num += x._num;
        if(_num >= MOD) _num -= MOD;
        return *this;
    }
    inline modint operator ++ () {
        _num++;
        if(_num == MOD) _num = 0;
        return *this;
    }
    inline modint operator -  (int x) {return modint(_num - x);}
    inline modint operator -  (modint x) {
        int a = _num - x._num;
        if(a < 0) a += MOD;
        return modint{a};
    }
    inline modint operator -= (int x) {
        _num -= x, _num %= MOD;
        if(_num < 0) _num += MOD;
        return *this;
    }
    inline modint operator -= (modint x) {
        _num -= x._num;
        if(_num < 0) _num += MOD;
        return *this;
    }
    inline modint operator -- () {
        _num--;
        if(_num == -1) _num = MOD - 1;
        return *this;
    }
    inline modint operator /  (int x) {return modint(_num * invmod(modint(x), MOD));}
    inline modint operator /  (modint x) {return modint{_num * invmod(x._num, MOD) % MOD};}
    inline modint operator /= (int x) {
        _num *= invmod(modint(x), MOD), _num %= MOD;
        return *this;
    }
    inline modint operator /= (modint x) {
        _num *= invmod(x._num, MOD), _num %= MOD;
        return *this;
    }
    inline modint operator *  (int x) {return modint(_num * (x % MOD));}
    inline modint operator *  (modint x) {return modint{_num * x._num % MOD};}
    inline modint operator *= (int x) {
        _num *= modint(x), _num %= MOD;
        return *this;
    }
    inline modint operator *= (modint x) {
        _num *= x._num, _num %= MOD;
        return *this;
    }
    inline modint pow(int x) {
        modint ans = 1, cnt = *this;
        for(int i = 1; i < x + 1; i *= 2) {
            if(x & i) ans *= cnt; x ^= i;
            cnt *= cnt;
        }
        return ans;
    }
    inline operator int() {return _num;}
};
vector<modint> fac(1, 1), inv(1, 1);
void reserve(int a) {
    if(fac.size() >= a) return;
    if(a < fac.size() * 2) a = fac.size() * 2;
    if(a >= MOD) a = MOD;
    while(fac.size() < a) fac.push_back(fac.back() * (int)(fac.size()));
    inv.resize(fac.size());
    inv.back() = modint(1) / fac.back();
    for(int i = inv.size() - 1; !inv[i - 1]; i--) inv[i - 1] = inv[i] * i;
}
modint comb(int n, int r){
    if(r < 0 || n < r) return 0;
    reserve(n + 1);
    return fac[n] * inv[r] * inv[n - r];
}
signed main() {
    INCANT;
    int x, y, res = 0;
    cin>>x>>y;
    if((x + y) % 3) cout<<0<<endl;
    else {
        int a = (2 * x - y) / 3, b = (2 * y - x) / 3;
        cout<<comb(a + b, a)<<endl;
    }
}


Measured memory_bytes: 12392