D=int(input()) s='' for i in range(1,56): s+=str(i) print(s[D-1])