import java.math.BigInteger;
import java.util.Scanner;
public class 阶乘 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
BigInteger sum = BigInteger.ONE;
for (int i = 1; i <= n; i++)
sum = sum.multiply(BigInteger.valueOf(i));
String s = sum.toString();
for (int i = s.length() - 1; i >= 0; i--)
if (s.charAt(i) != '0') {
System.out.println(s.charAt(i));
break;
}
}
}