N = int(input()) l = [2,8,5,7,1,4] N = N % 6 if N == 0: N = 6 print(l[N-1])