import sys

input = []

for line in sys.stdin:
	input.append(line.split())

n = int(input[0][0])
m = int(input[0][1])


MOD = 10**9 + 1

cache = {}
def f(n):
	if n == 1 or n == 2:
		return 1
	if n not in cache:
		h = f(n / 2)
		h1 = f(n / 2 + 1)
		if n & 1 == 1:
			cache[n] = (h1 * h1 % MOD) + (h * h % MOD) % MOD
		else:
			cache[n] = h * (2 * h1 - h)
	return cache[n]

res = 2 * ((f(n + 1) + f(m + 1) - 1) % MOD)
res %= MOD

print(res)


