def ans(n): return [2, 8, 5, 7, 1, 4][(n - 1) % 6] n = int(input()) print(ans(n))