xs = list('285714') n = int(input()) % len(xs) print(xs[n-1])