n = int(input()) s = "285714" i = n % len(s) - 1 ans = s[i] print(ans)