#include <iostream>
using namespace std;
int main()
{
int n; cin >> n;
int c = 1, d2 = 0, d5 = 0;
for(int i = 1; i <= n; i ++ ){
int t = i;
while(t % 2 == 0) t /= 2, d2 ++ ;
while(t % 5 == 0) t /= 5, d5 ++ ;
c = c * t % 10;
}
for(int i = 0; i < d2 - d5; i ++ )
c = c * 2 % 10;
cout << c << endl;
return 0;
}