n = int(input()) lst = "285714" print(lst[(n - 1)% 6])