import math N = int(input()) #print(N) f,i = math.modf(2/7) f = "".join(str(f)) #print(f) print(f[N+1])