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