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