n = int(input()) cycle = [2, 8, 5, 7, 1, 4] index = (n - 1) % 6 print(cycle[index])