n = input() n = int(n) jc = 1 for i in range(1,n+1): jc *= i while(jc%10 == 0): jc/=10 print(int(jc%10))