void main() {
    long[] tmp = readln.split.to!(long[]);
    long x = tmp[0], y = tmp[1];
    long mod = 10 ^^ 9 + 7;
    long ans;
    if ((x + y) % 3 == 0) {
        long n = (2 * y - x) / 3, m = (2 * x - y) / 3;
        if (n >= 0 && m >= 0) {
            long l = n+m;
            long[] fac = new long[l+1];
            long[] finv = new long[l+1];
            long[] inv = new long[l+1];
            fac[0] = 1, fac[1] = 1;
            finv[0] = 1, finv[1] = 1;
            inv[1] = 1;
            foreach (i; 2 .. l+1) {
                fac[i] = fac[i-1] * i % mod;
                inv[i] = mod - inv[mod%i] * (mod / i) % mod;
                finv[i] = finv[i-1] * inv[i] % mod;
            }
            long comb(long x, long y) {
                if (x < y) return 0;
                if (x < 0 || y < 0) return 0;
                return fac[x] * (finv[y] * finv[x-y] % mod) % mod;
            }
            ans = comb(n+m, n);
        }
    }
    ans.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;