N = int(input()) S = '428571' for i in range (5): if (N % 6) == i: print(S[i])