#include<bits/stdc++.h> using namespace std; int main() { int a; cin>>a; int i=1;long long b=1; while(i<a) {b=b*(i+1);i++;} i=10; while(b%i==0) { b=b/10; } cout<<b%i<<endl; return 0; }