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

using namespace std;

int mod = 1e9 + 7;

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

signed main()
{
    int x, y;
    cin >> x >> y;
    if (2 * x - y < 0 || (2 * x - y) % 3 != 0)
    {
        cout << 0 << '\n';
        exit(0);
    }
    if (2 * y - x < 0 || (2 * y - x) % 3 != 0)
    {
        cout << 0 << '\n';
        exit(0);
    }
    int a = (2 * x - y) / 3, b = (2 * y - x) / 3;
    vector<int> f(1, 1);
    for (int i = 1; i < 1e6; i++)
    {
        f.push_back(f[i - 1] * i % mod);
    }
    cout << f[a + b] * (f2(f[a], mod - 2) % mod) % mod * (f2(f[b], mod - 2) % mod) % mod;
}
