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

require 'matrix'

def mpow(x, n)
  ret = 1
  while n > 0
    if n.even?
      x = x * x % M
      n >>= 1
    else
      ret = ret * x % M
      n -= 1
    end
  end
  ret
end

f = ->(a, b){(a .. b).inject(1){|r, x| r * x % M}}
a, b = Matrix[[2, 1], [1, 2]].lup.solve([X, Y]).to_a
unless a.denominator == 1 && b.denominator == 1
  puts 0
else
  a, b = a.to_i, b.to_i
  n = a + b
  k = [a, b].min
  puts f[n - k + 1, n] * mpow(f[1, k], M - 2) % M
end