N = input() a = [2, 8, 5, 7, 1, 4] print(a[N%6 - 1])