#include <bits/stdc++.h>

using namespace std;

#define _ << " " <<
#define pb push_back
#define ff first
#define ss second


typedef long long ll;
typedef long double ld;

#define int ll

const ll MOD = 1e9 + 7;

vector<int> fact(2e6 + 100);

void  build() {
    fact[0] = 1;
    for (int i = 1; i < fact.size(); ++i) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
    }
}

int pw(int x, int y) {
    if (y == 0) return 1;
    if (y % 2 == 0) return pw(x * x % MOD, y / 2) % MOD;
    return (x * pw(x, y - 1)) % MOD;
}

void solve() {
    ll i, j;
    cin >> i >> j;
    if ((2 * j - i) % 3 != 0 || (2 * i - j) % 3 != 0) {
        cout << 0;
    } else {
        ll x = (2 * j - i) / 3 % MOD;
        ll y = (2 * i - j) / 3 % MOD;
        //cout << x _ y << endl;
        cout << (fact[x + y] * pw(fact[x], MOD - 2)) % MOD * pw(fact[y], MOD - 2) % MOD;
    }
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("dominoes.in", "r", stdin);
    //freopen("dominoes.out", "w", stdout);
    int test = 1;
    //cin >> test;
    build();
    while (test--) {
        solve();
    }
}
