D = int(input()) print("".join([str(i) for i in range(1, (D + 8) // 2 + 2)])[D - 1])