def combi (n, k)
  k = n - k if 2 * k > n
  return 1 if k == 0
  ((n - k + 1)..n).reduce(&:*)/((1..k).reduce(&:*))
end

x, y = gets.split.map(&:to_i)
if (x + y) % 3 != 0
  puts 0
  exit
end

# X = n + 2m
# Y = 2n + m
# 2x - y = 3m
# m = 2/3x - 1/3 x
m = (2 * x - y) / 3
n = x - 2 * m

if m < 0 || n < 0
  puts 0
  exit
end

puts combi(n+m, n)
