#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<vector>
#include<set>

using namespace std;
long long fa[2000000], a[1010];
long long gcd(long long a, long long b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

double eps = 0.0000001;
const long long mod = 1e9+7;


int fn;

long long bp(long long a, long long n, long long m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return bp((a*a) % m, n / 2, m);
	else
		return (a%m) * bp(a%m, n - 1, m) % m;
}

int cnk(int a, int b) {
	return (fa[a + b] * bp(fa[a], mod - 2, mod)) % mod * bp(fa[b], mod - 2, mod) % mod;
}

long long lcm(long long a, long long b) {
	return (a / gcd(a, b)) * b;
}



signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int x, y;
	cin >> x >> y ;
	long long ans = 1;
	fa[0] = 1;
	for (int i = 1; i <= 2000000; i++) {
		fa[i] = (fa[i - 1] * i) % mod;
		fa[i] %= mod;
	}
	//cout << cnk(x, y) << endl;
	if (x > y)
		swap(x, y);
	int c = y - x;
	x -= c;
	if (x < 0 || x % 3 != 0) {
		cout << 0;
	}
	else {
		cout << cnk(x / 3, x / 3 + c);
	}
	//system("pause");
	return 0;
}