import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

void scan(T...)(ref T args) {
    auto line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x > arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args) if (x < arg) {
        x = arg;
        isChanged = true;
    }
    return isChanged;
}


enum mod = 1_000_000_007L;

struct Mint {
    long x;

    this(long a) {
        x = a % mod;
        if (x < 0) x += mod;
    }

    this(Mint a) {
        x = a.x;
    }

    ref Mint opAssign(long a) {
        this = Mint(a);
        return this;
    }

    ref Mint opOpAssign(string op)(Mint rhs) {
        static if (op == "+") {
            x += rhs.x;
            if (x >= mod) x -= mod;
        }
        static if (op == "-") {
            x -= rhs.x;
            if (x < 0) x += mod;
        }
        static if (op == "*") {
            (x *= rhs.x) %= mod;
        }
        static if (op == "/") {
            this *= rhs.inv();
        }
        return this;
    }

    ref Mint opOpAssign(string op)(long rhs) {
        static if (op == "^^") {
            this = powmod(this, rhs);
            return this;
        }
        else {
            return mixin("this " ~ op ~ "= Mint(rhs)");
        }
    }

    const Mint powmod(Mint a, long b) {
        Mint res = 1, p = a;
        while (b > 0) {
            if (b & 1) res *= p;
            p *= p;
            b /= 2;
        }
        return res;
    }

    const Mint inv() {
        return powmod(this, mod - 2);
    }

    Mint opUnary(string op)() if (s == "-") {
        return Mint(-x);
    }

    Mint opBinary(string op, T)(const T rhs) {
        return mixin("Mint(this) " ~ op ~ "= rhs");
    }

    Mint opBinaryRight(string op)(const long rhs) {
        return mixin("Mint(rhs) " ~ op ~ "= this");
    }

    bool opEquals(Mint a, Mint b) {
        return a.x == b.x;
    }

    bool opEquals(long rhs) {
        long y = rhs % mod;
        if (y < 0) y += mod;
        return x == y;
    }

    string toString() {
        import std.conv : to;
        return x.to!string;
    }
}

struct ModComb {
    int N;
    Mint[] fact, ifact;

    this(int n) {
        N = n;
        fact = new Mint[](N + 1);
        ifact = new Mint[](N + 1);

        fact[0] = 1;
        foreach (i ; 1 .. N + 1) {
            fact[i] = fact[i - 1] * i;
        }

        ifact[N] = 1 / fact[N];
        foreach_reverse (i ; 0 .. N) {
            ifact[i] = ifact[i + 1] * (i + 1);
        }
    }

    Mint c(int n, int k) {
        if (n < 0 || k < 0 || k > n) return Mint(0);
        return fact[n] * ifact[n - k] * ifact[k];
    }

    Mint p(int n, int k) {
        if (n < 0 || k < 0 || k > n) return Mint(0);
        return fact[n] * ifact[n - k];
    }
}

unittest {
    auto mc = ModComb(1_000_000);
    assert(mc.c(5, 2) == 10);
    assert(mc.c(6, 3) == 20);
    assert(mc.c(3, 1) == 3);
    assert(mc.c(0, 0) == 1);
    assert(mc.c(3, 4) == 0);
    assert(mc.c(3, -1) == 0);
    assert(mc.c(-1, 0) == 0);
    assert(mc.c(40, 20) == 846527861);

    assert(mc.p(5, 2) == 20);
    assert(mc.p(6, 3) == 120);
    assert(mc.p(3, 1) == 3);
    assert(mc.p(0, 0) == 1);
    assert(mc.p(3, 4) == 0);
    assert(mc.p(3, -1) == 0);
}

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;


void main() {
    int x, y;
    scan(x, y);

    Mint ans;
    auto mc = ModComb(x + y);
    foreach (r ; 0 .. x + 1) {
        int xx = x - r, yy = y - 2*r;
        if (xx != 2 * yy) continue;
        ans += mc.c(r + yy, r);
    }
    writeln(ans);
}


Measured memory_bytes: 34684