#include <bits/stdc++.h>
#define mod 1000000007

using namespace std;

long long mypow(long long x, long long y) {
    if (!y) {
        return 1;
    } else if (!(y % 2)) {
        long long k = x * x % mod;
        if (k < 0) {
            k += mod;
        }
        return mypow(k, y / 2);
    } else {
        long long k = (mypow(x, y - 1) * x) % mod;
        if (k < 0) {
            k += mod;
        }
        return k;
    }
}


long long fact[3000005];


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    long long x, y;
    cin >> x >> y;

    fact[0] = 1;
    for (long long i = 1; i < 3000005; ++i) {
        fact[i] = (fact[i - 1] * i) % mod;
    }


    long long a = (2 * y - x) / 3, b = (2 * x - y) / 3;

    if ((2 * y - x) % 3 || (2 * x - y) % 3) {
        cout << 0;
        return 0;
    }

    cout << (((fact[a + b] * mypow(fact[b], mod - 2)) % mod) * mypow(fact[a], mod - 2)) % mod;




}