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