#include <iostream>
using namespace std;
int main()
{
int n;
int res = 1;
cin >> n;
for (int i = 1; i <= n; i++)
{
res = res * i;
while (!(res % 10))
{
res = res / 10;
}
res = res % 10000000;
}
cout << res % 10;
}