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

enum ulong 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;
}

N modfact(N)(N st, N ed, N m) {
  assert(m != 0);
  
  N x = 1;
  foreach (i; st..ed+1) x = (x*(i%m)) % m;
  return x;
}

N modcomb(N)(N n, N r, N m) {
  assert(n != 0);
  assert(m != 0);
  
  const num = modfact(n-r+1, n, m);
  const den = modfact(1,     r, m);
  return (num * den.modinv(m)) % m;
}

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