A = str(285714) N = int(input()) L = N % len(A) print(A[L-1])