#include <bits/stdc++.h>
#define int long long

using namespace std;

int mod = 1e9 + 7;

int po(int a, int x){
    if(a == 1){
        return x;
    }
    if(a % 2){
        return po(a / 2, x * x % mod) * x % mod;
    }
    return po(a / 2, x * x % mod);
}

void solve(){
    int x, y;
    cin >> x>> y;
    int a = (2 * x - y), b = (2 * y - x);
    if(a < 0 || b < 0 || a % 3 || b % 3){
        cout << 0;
        return;
    }
    a /= 3; b /= 3;
    int t = 1, t1 = 1, t2 = 1;
    for(int i = 1; i <= a + b; i++){
        t = t * i % mod;
    }
    for(int i = 1; i <= a; i++){
        t1 = t1 * i % mod;
    }
    for(int i = 1; i <= b; i++){
        t2 = t2 * i % mod;
    }
    //cout << t << ' ' << t1 << ' ' << t2 << endl;
    cout << t * po(mod - 2, t1) % mod * po(mod - 2, t2) % mod;
}


signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int test = 1;
    //freopen("output.txt", "w", stdout);
    //freopen("input.txt", "r", stdin);
    //cin >> test;
    while(test--){
        solve();
    }
}
