#include <iostream>
#include <cstdint>
#include <cmath>
#include <climits>
#include <cassert>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>

#define rep(i,n) for(int i = 0; i < (n); ++i)

using namespace std;

template<class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template<class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for(auto& item : collection) is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

class modint_t {
public:
    modint_t() = default;
    modint_t(int64_t value):value(value % MOD){}

    bool operator<(const modint_t rhs) const { return value < rhs.value; }
    bool operator<=(const modint_t rhs) const { return value <= rhs.value; }
    bool operator>(const modint_t rhs) const { return value > rhs.value; }
    bool operator>=(const modint_t rhs) const { return value >= rhs.value; }

    modint_t operator+(const modint_t rhs) const { return modint_t(value + rhs.value); }
    modint_t operator+=(const modint_t rhs) { return value = (value + rhs.value) % MOD; }
    modint_t operator-(const modint_t rhs) const { return modint_t(MOD + value - rhs.value); }
    modint_t operator-=(const modint_t rhs) { return value = (MOD + value - rhs.value) % MOD; }

    modint_t operator*(const modint_t rhs) const { return modint_t(value * rhs.value); }
    modint_t operator*=(const modint_t rhs) { return value = value * rhs.value % MOD; }
    modint_t operator/(const modint_t rhs) const { return *this * rhs.invert(); }
    modint_t operator/=(const modint_t rhs) { return *this *= rhs.invert(); }

    modint_t square() const { return *this * *this; }
    modint_t power(int64_t y) const
    {
        if(y == 0) return 1;
        else if(y == 1) return *this;
        else if(y % 2 == 0) return this->power(y/2).square();
        else return *this * this->power(y-1);
    }

    modint_t invert() const
    {
        return power(MOD-2);
    }

    operator int64_t() const
    {
        return value;
    }
private:
    static const int MOD = 1000000007;
    int64_t value = 0;
};

modint_t factorial(int64_t n)
{
    if(n <= 1) return 1;
    modint_t f = 1;
    for(int64_t i = 1; i <= n; ++i)
    {
        f *= i;
    }
    return f;
}

void solution()
{
    int x,y;
    cin >> x >> y;
    int x2 = 2 * x - y;
    int y2 = -x + 2 * y;
    if(x2 < 0 || y2 < 0 || x2 % 3 != 0 || y2 % 3 != 0){
        cout << "0\n";
        return;
    }
    x2 /= 3;
    y2 /= 3;
    cout << factorial(x2 + y2) / (factorial(x2) * factorial(y2)) << '\n';
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solution();
    return 0;
}


Measured memory_bytes: 256