import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines MOD = 1000 class Qint(): def __init__(self,a,b): self.x = a self.y = b def __mul__(self,other): x = self.x * other.x + 3 * self.y * other.y y = self.x * other.y + self.y * other.x return Qint(x%MOD,y%MOD) def __repr__(self): return '({}) + ({})sqrt 3'.format(self.x, self.y) def __pow__(self,n): if n == 0: return Qint(1,0) x = self ** (n//2) x *= x return self * x if n & 1 else x def f(N): q = Qint(1,1) ** N x = q.x * 2 % MOD if N == 0: return 1 elif N & 1: return x else: return (x - 1) % MOD # f(0), f(2), f(12), f(123456789) N = int(read()) answer = f(N) print(answer)