#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("lastnum.inp","r",stdin);
    freopen("lastnum.out","w",stdout);
    int64_t n;
    cin>>n;
    int64_t r=1;
    for(int64_t i=2;i<=n;i++)
    {
        r*=i;
        if(i%5==0)
        {
            r/=10;
        }
        r%=10;
    }
    cout<<r;
}
