import java.util.*;
public class solutionBigFact{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
String s = Long.toString(fact( n));
if(s.length()>4){
int b = Integer.parseInt(s.substring(s.length()-4));
System.out.println(b);
}
if(s.length()<=4){
int b = Integer.parseInt(s);
System.out.println(b);
}
sc.close();
}
public static long fact(long n){
if(n==0||n==1){
return 1;
}
return fact(n-1)*n;
}
}