X,Y = gets.split.map &:to_i
MOD = 10 ** 9 + 7

TT = Y * 2 - X
SS = X * 2 - Y
if TT % 3 != 0 || SS % 3 != 0
  puts 0
  exit
end

T = TT / 3
S = SS / 3

def fact(n)
  ans = 1
  1.upto(n) do |i|
    ans *= i
    ans %= MOD
  end
  ans
end

# ans = 1
# ans *= fact(S+T)

# SSS = fact(S)
# TTT = fact(T)

# (MOD-2).times do
#   ans *= SSS
#   ans %= MOD
#   ans += TTT
#   ans %= MOD
# end

A = (1..S).inject(:*)
B = (1..T).inject(:*)
C = (1..S+T).inject(:*)

puts C/A/B%MOD