program metro;
var N,F,R:longint;
begin
assign (input,'input.txt');
reset (input);
assign (output,'output.txt');
rewrite (output);
Read (N);
F:=1;
R:=1;
While R<=N do
Begin
F:=F*R;
R:=R+1;
If F mod 10=0 then Begin
F:=F div 10;
If F mod 10=0 then F:=F div 10
End;
If F>999999 then F:=F mod 10;
End;
If F mod 10<>0 then Write (F mod 10)
else Write (F mod 10);
End.