var
now,n,i:longint;
f:array[0..1000]of longint;
begin
assign(input,'baga.in'); reset(input);
assign(output,'baga.out'); rewrite(output);
readln(n);
f[0]:=1;
f[1]:=1;
f[2]:=5;
now:=0;
for i:=3 to n do
begin
f[now]:=f[(now+2) mod 3]+f[(now+1) mod 3]*4+f[now mod 3]*2;
f[now]:=f[now] mod 997;
if i=n then writeln(f[now]);
now:=(now+1) mod 3;
end;
close(input);
close(output);
end.