var
n,i,sum,ans:integer;
a:array[1..4220] of integer;
function f(x,y,z:integer):integer;
begin
if (z=-1) and (sum=0) then
exit(x);
if x mod y<>0 then
exit(x);
inc(sum,z);
f:=f(x div y,y,z);
end;
begin
assign(input,'fact4.in');
assign(output,'fact4.out');
reset(input);
rewrite(output);
//while not(eof) do
//begin
readln(n);
sum:=0;
for i:=2 to n do
begin
if i mod 5=0 then
a[i]:=f(i,5,1)
else
a[i]:=i;
end;
for i:=2 to n do
if sum=0 then
break
else
if a[i] mod 2=0 then
a[i]:=f(a[i],2,-1);
ans:=1;
for i:=2 to n do
ans:=ans*a[i] mod 10;
writeln(ans);
//end;
close(input);
close(output);
end.