#include<bits/stdc++.h>

using namespace std;

#define int long long

int MOD = 1e9 + 7;

vector<int> pred(700000);

void fact() {
    pred[0] = 1;
    for (int x = 1; x <= 700001; ++x) {
        pred[x] = pred[x - 1] * x % MOD;
    }
}

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

signed main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fact();
    int x, y;
    cin >> x >> y;
    int kol_1 = 0;
    int kol_2 = 0;
    for (int i = 0; i < 500050; ++i) {
        if (x - i * 1 >= 0 && x - i * 1 == (y - i * 2) * 2) {
            kol_1 = i;
            kol_2 = y - i * 2;
        }
        //cout << "* " << i << endl;
    }
    if (kol_1 + kol_2 == 0) {
        cout << 0 << endl;
    }
    else {
        //cout << "!!! " << kol_1 + kol_2;
        int now = pred[kol_1 + kol_2];
        now *= pw(pred[kol_1], MOD - 2);
        now %= MOD;
        now *= pw(pred[kol_2], MOD - 2);
        now %= MOD;
        cout << now << endl;
    }
    return 0;
}

