#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout <<"DEBUG"<<" "<<#x<<":"<<x<<'\n'

//↓0-indexか1-indexでn回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-index昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-index昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-index降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-index降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<class T,class U> inline bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U> inline bool chmin(T &a, const U &b){if(a>b){a=b;return 1;}return 0;}

/* 円周率は M_PI を使おうね */
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int_fast64_t MOD = 1000000007;
/*FUNCs=================================================*/

/*MOD int=============================*/
template<std::int_fast64_t Mod>
class modint {
    using i64 = std::int_fast64_t;
private:
    i64 a;

public:
    //constructor
    constexpr modint(const i64 p=0) noexcept : a(p>=0?p%Mod:(Mod+(p%Mod))%Mod) {}

    //std::cin, std::cout
    friend std::ostream &operator<<(std::ostream &os, const modint &x) {
        os << x.a;
        return os;
    }
    friend std::istream &operator>>(std::istream &is, modint &x) {
        is >> x.a;
        x.a %= Mod;                   // <- 負数対応
        if(x.a < 0) x.a += Mod;
        if(x.a>=Mod) x.a %= Mod;
        return is;
    }

    //operator
    constexpr modint operator+(const modint b) const noexcept {
        return modint(*this) += b;
    }
    constexpr modint operator-(const modint b) const noexcept {
        return modint(*this) -= b;
    }
    constexpr modint operator*(const modint b) const noexcept {
        return modint(*this) *= b;
    }
    constexpr modint operator/(const modint b) const noexcept {
        return modint(*this) /= b;
    }

    constexpr modint &operator=(const modint b) noexcept {
        a = b.a;
        return *this;
    }
    constexpr modint &operator+=(const modint b) noexcept {
        a += b.a;
        if(a >= Mod) a -= Mod;
        return *this;
    }
    constexpr modint &operator-=(const modint b) noexcept {
        if(a < b.a) a += Mod;
        a -= b.a;
        return *this;
    }
    constexpr modint &operator*=(const modint b) noexcept {
        a = a * b.a % Mod;
        return *this;
    }
    constexpr modint &operator/=(modint b) noexcept {
        a *= b.inverse().a;
        a %= Mod;
        return *this;
    }
    constexpr modint inverse() noexcept {
        i64 m=Mod, u=1, v=0, t=1;
        while(m) {
            t = a/m;
            a -= t*m; swap(a,m);
            u -= t*v; swap(u,v);
        }
        u %= Mod;
        if(u < 0) u += Mod;
        return modint(u);
    }
};
/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    //cout << fixed << setprecision(15);
    
    int x, y; cin >> x >> y;
    int a, b;
    if((2*y-x)%3!=0) {
        cout << 0 << '\n';
        return 0;
    } 
    if((2*x-y)%3!=0) {
        cout << 0 << '\n';
        return 0;
    }
    a = (2*x-y)/3;
    b = (2*y-x)/3;
    if(a<0||b<0) {
        cout << 0 << '\n';
        return 0;
    }

    modint<MOD> answer(1), P;

    for(int i = a+b; i >= b+1; --i) {
        P = modint<MOD>(i);
        answer *= P;
    }
    for(int i = 1; i <= a; i++) {
        P = modint<MOD>(i);
        answer /= P;
    }

    cout << answer << '\n';
}

Measured memory_bytes: 256