import std.stdio, std.algorithm, std.conv, std.string, std.array, std.math, std.range, std.container.dlist;

enum long MOD = 1000000007;

N modinv(N)(N x, N m) {
  assert(m != 0);
  
  N y = m, u = 1, v = 0;
  while (y) {
    const t = x / y;
    x -= t*y; swap(x, y);
    u -= t*v; swap(u, v);
  }
  u %= m;
  if (u < 0) u += m;
  return u;
}

immutable facts = {
  long[1000000] result;
  result[0] = 1;
  foreach (i; 1..result.length) result[i] = result[i-1]*i % MOD;
  return result;
}();
immutable facts_inv = {
  long[1000000] result;
  result[$-1] = facts[$-1].modinv(MOD);
  foreach_reverse (i; 0..result.length-1) result[i] = result[i+1]*((i+1)%MOD) % MOD;
  return result;
}();

N nCr(N)(N n, N r) {
  if (n < r || r < 0) return 0;
  return (facts[n] * facts_inv[r] % MOD) * facts_inv[n-r] % MOD;
}

void main() {
  long X, Y;
  readf(" %d %d ", &X, &Y);
  
  const move_count = (X+Y)/3;
  if (move_count*3 != X+Y) {
    0.writeln;
    return;
  }
  
  nCr(move_count, X-move_count).writeln;
}