#include <bits/stdc++.h>
#define int long long
using namespace std;

const int MOD = 1e9 + 7;
vector<int> fact(2e6 + 2, 1);

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

int add(int a, int b) {
    return (a + b) % MOD;
}

int mul(int a, int b) {
    return (a * b) % MOD;
}

int div(int b) {
    return pw(b, MOD - 2) % MOD;
}

void solve() {
    for (int i = 2; i < 2e6 + 2; ++i) {
        fact[i] = fact[i - 1] * i % MOD;
    }
    int i, j;
    cin >> i >> j;
    int x = (2 * i - j) / 3, y = (2 * j - i) / 3;
    cout << mul(fact[x + y], mul(div(fact[x]), div(fact[y]))) % MOD << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}



