https://www.acwing.com/problem/content/1383/
#include<bits/stdc++.h>
using namespace std;
const long long int N=1e4;
long long int n;
int main(){
cin>>n;
long long b=1;
for(long long int i=n;i>=1;i--)
{
//long long int b;
if((i*b)%N!=0)b=(i*b)%N;
else {
b=i*b;
while(!(b%N))
{
b=b/N;
}
}
}
while(b%10==0)b/=10;
cout<<b%10<<endl;
return 0;
}