#include <bits/stdc++.h>

using namespace std;

#define TASK "c"
#define int long long


map<pair<int, int>, int> a;
const int MOD = 1e9 +7;
int f(int x, int y) {
    if (a.count({x, y})) return a[{x, y}];
    if (x < 0 || y < 0) return 0;
    a[{x, y}] = (f(x - 1, y - 2) + f(x - 2, y - 1)) % MOD;
    return a[{x, y}];
}

void solve() {
    int x, y;
    cin >> x >> y;
    a[{0, 0}] = 1;
    cout << f(x, y);

}

signed main() {
    //freopen(TASK".in", "r", stdin);freopen(TASK".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
//    cout<<"7";
    solve();
}