MOD = 1000000007
INV = []

def conv(a,b)
  if b > a/2
    b = a - b
  end
  ans = 1
  for i in 1..b
    ans = ((ans * (a - (i - 1))) * INV[i]) % MOD
  end
  ans % MOD
end

def pow(x,n)
  if n == 0
    1
  elsif n % 2 == 0
    pow(x*x%MOD, n/2) % MOD
  else
    x * pow(x, n-1) % MOD
  end
end

def calc_fact(n)
  INV[0] = pow(1, MOD-2)
  for i in 1..n
    INV[i] = pow(i, MOD-2)
  end
end

x,y=gets.chomp.split(" ").map(&:to_i)

if (x + y) % 3 != 0
  puts "0"
  exit
end

n = (x + y) / 3
x = x - n
y = y - n
if x < 0 || y < 0
  puts "0"
  exit
end

calc_fact(x > y ? x : y)
puts conv(x + y, x)