program bly(input,output);
var
f:array[0..10000] of int64;
f1,f2:text;
n:longint;
i,j:integer;
begin
assign(f1,'circlex.in');
reset(f1);
readln(f1,n);
close(f1);
f[0]:=1; f[1]:=1;
for i:=2 to n do begin
for j:=0 to i-2 do f[i]:=(f[i]+f[j]*f[i-j-2]) mod 12345;
f[i]:=(f[i]+f[i-1]) mod 12345;
end;
assign(f2,'circlex.out');
rewrite(f2);
writeln(f2,f[n]);
close(f2);
end.