n = int(input()) f = '285714' print(int(f[(n % 6) -1]))