def f_mat_square(mat_size, mat):
new_mat = [[0 for i in range(mat_size)] for j in range(mat_size)]
for arow in range(0, mat_size):
for acol in range(0, mat_size):
for brow in range(0, mat_size):
new_mat[arow][acol] += mat[arow][brow] * mat[brow][acol]
return new_mat
def f_mat_product(m1,m2,mat_size):
new_mat = [[0 for i in range(mat_size)] for j in range(mat_size)]
for arow in range(mat_size):
for acol in range(mat_size):
for brow in range(mat_size):
new_mat[arow][acol] += m1[arow][brow] * m2[brow][acol]
for row in range(mat_size):
for col in range(mat_size):
new_mat[row][col] = new_mat[row][col] % 1000000
return new_mat
expo = [1]
for i in range(1, 18*3+200):
expo.append(2 * expo[len(expo) - 1])
mat_size = 2
mat_squa = input()
mat = [[1,1],[1,0]]
mat_square_list = []
mat_square_list.append(mat)
for step in range(0, 18*3+100):
new_mat = f_mat_square(mat_size, mat)
for row in range(0, mat_size):
for col in range(0, mat_size):
new_mat[row][col] %= 1000000
mat_square_list.append(new_mat)
mat = new_mat
index = len(mat_square_list)
ans_mat = [[0 for i in range(mat_size)] for j in range(mat_size)]
for row in range(mat_size):
for col in range(mat_size):
if(row == col):
ans_mat[row][col] = 1
while(mat_squa > 0):
if(mat_squa >= expo[index]):
mat_squa -= expo[index]
ans_mat = f_mat_product(ans_mat, mat_square_list[index], mat_size)
elif(mat_squa < expo[index]):
index -= 1
print ans_mat[1][0]