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