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

s_cache = {}
def s(n):
	if n == 1:
		return 0
	if n == 2:
		return 1
	if n not in s_cache:
		s_cache[n] = (s(n - 2) + d(n - 1)) % MOD
	return s_cache[n]

d_cache = {}
def d(n):
	if n == 1:
		return 1
	if n == 2:
		return 1
	if n not in d_cache:
		d_cache[n] = (s(n - 1) + d(n - 1)) % MOD
	return d_cache[n]

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

sys.stdout.write(str(res))


