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