Testing Round 15 (Unrated) |
---|

Finished |

Virtual contest is a way to take part in past contest, as close as possible to participation on time. It is supported only ICPC mode for virtual contests.
If you've seen these problems, a virtual contest is not for you - solve these problems in the archive.
If you just want to solve some problem from a contest, a virtual contest is not for you - solve this problem in the archive.
Never use someone else's code, read the tutorials or communicate with other person during a virtual contest.

binary search

divide and conquer

implementation

*1800

No tag edit access

The problem statement has recently been changed. View the changes.

×
B. Digits Sequence (Hard Edition)

time limit per test

1 secondmemory limit per test

256 megabytesinput

standard inputoutput

standard outputLet's write all the positive integer numbers one after another from $$$1$$$ without any delimiters (i.e. as a single string). It will be the infinite sequence starting with 123456789101112131415161718192021222324252627282930313233343536...

Your task is to print the $$$k$$$-th digit of this sequence.

Input

The first and only line contains integer $$$k$$$ ($$$1 \le k \le 10^{12}$$$) — the position to process ($$$1$$$-based index).

Output

Print the $$$k$$$-th digit of the resulting infinite sequence.

Examples

Input

7

Output

7

Input

21

Output

5

Codeforces (c) Copyright 2010-2024 Mike Mirzayanov

The only programming contests Web 2.0 platform

Server time: Apr/20/2024 10:17:47 (l1).

Desktop version, switch to mobile version.

Supported by

User lists

Name |
---|