X, Y = gets.chomp.split.map(&:to_i)

ans = 0
que = [[X, Y]]
while !que.empty?
  x, y = que.shift
  if x < 0 || y < 0 || (x + y) % 3 != 0 || (x > 2*y) || (y > 2*x)
  elsif (x == 2*y) || (y == 2*x)
    ans += 1
    ans = 0 if ans == 1000000007
  else
    que.push([x-2, y-1])
    que.push([x-1, y-2])
  end
end

p ans
