#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

template<typename T = int64_t>
struct Combination
{
public:

  /** 符号付き整数を推奨 */
  using com_int = T;

  /** 特に必要はない */
  int mInf;

  /** modを取るので */
  com_int mMod;

  /** (n!)のメモ帳 */
  vector<com_int> fac;

  /** modinvするので */
  vector<com_int> inv;

  /** (k!)^-1のメモ帳 */
  vector<com_int> finv;

  /**
   * @param N nCkで指定するnの最大（デフォルト値は何となく）
   * @param m modを取るので（デフォルト値は10^9 + 7）
   */
  Combination(int N = 10^5, int m = MOD)
    : mInf(N)
    , mMod(m)
    , fac(N+1)
    , inv(N+1)
    , finv(N+1)
  {
    init();
  }

  /**
   * 前計算を行う.
   * operator()呼び出しの前に必ず実行すること.
   */
  void init() {
    fac[0]  = fac[1]  = com_int(1);
    finv[0] = finv[1] = com_int(1);
    inv[0] = -1;
    inv[1] = com_int(1);

    for (int i = 2; i < (int)fac.size(); ++i) {
      fac[i] = (fac[i - 1] * i) % mMod;
      inv[i] = mMod - (inv[mMod % i] * (mMod / i)) % mMod;
      finv[i] = (finv[i - 1] * inv[i]) % MOD;
    }
  }

  /**
   * 二項係数を計算する
   * @param n
   * @param k
   * @return nCk (mod m)
   */
  com_int operator()(int n, int k) {
    if (n < k) {
      return com_int(0);
    }
    if (n < 0 || k < 0) {
      return com_int(0);
    }
    if (n > mInf) {
      throw std::runtime_error("nが大きすぎる");
    }
    com_int ret{1};
    ret *= fac[n];
    ret %= mMod;
    ret *= finv[k];
    ret %= mMod;
    ret *= finv[n - k];
    ret %= mMod;
    return ret;
  }
};

void solve(void)
{
  ll X, Y; cin >> X >> Y;
  ll Z = Y - X;
  ll a{}, b{};
  if (Z > 0) {
    ll c = 2*Z + X;
    if (c % 3 != 0) {
      cout << 0 << CRLF;
      return;
    }
    a = c / 3;
    b = a - Z;
  } else if (Z < 0) {
    Z = -Z;
    ll c = Z + X;
    if (c % 3 != 0) {
      cout << 0 << CRLF;
      return;
    }
    b = c / 3;
    a = b - Z;
  } else {
    if (X % 3 != 0) {
      cout << 0 << CRLF;
      return;
    }
    ll c = 2*Y - X;
    if (c % 3 != 0) {
      cout << 0 << CRLF;
      return;
    }
    b = c / 3;
    a = b - Z;
  }

  Combination<> c(a+b);
  auto ans = c(a+b, a);
  // init(a + b + 1);
  // auto ans = comb(a + b, a);

  cout << ans << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 15872