import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
final long n
= Long.
parseLong( br.
readLine() ); System.
out.
println( solve
( n
) ); }
public static char solve( final long n ) {
if ( n < 10 ) {
return (char)( '0' + n );
} else {
return part( n - 10, 2 );
}
}
private static char part( final long nth, final int digCount ) {
if ( nth == 0 ) return '1';
long pow = 1;
for ( int i = 1; i < digCount; ++i ) {
pow *= 10;
}
final long firstInPart = pow;
final long partSize = digCount * 9 * pow;
if ( nth > partSize ) { // skip that part
return part( nth - partSize, digCount + 1 );
}
final long number = nth / digCount;
final long digitIndex = nth % digCount;
return Long.
toString( firstInPart
+ number
).
charAt( (int)digitIndex
); }
}
aW1wb3J0IGphdmEuaW8uQnVmZmVyZWRSZWFkZXI7CmltcG9ydCBqYXZhLmlvLklucHV0U3RyZWFtUmVhZGVyOwoKcHVibGljIGNsYXNzIE1haW4gewoKICAgIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKCBmaW5hbCBTdHJpbmdbXSBhcmdzICkgdGhyb3dzIEV4Y2VwdGlvbiB7CiAgICAgICAgZmluYWwgQnVmZmVyZWRSZWFkZXIgYnIgPSBuZXcgQnVmZmVyZWRSZWFkZXIoIG5ldyBJbnB1dFN0cmVhbVJlYWRlciggU3lzdGVtLmluICkgKTsKICAgICAgICBmaW5hbCBsb25nIG4gPSBMb25nLnBhcnNlTG9uZyggYnIucmVhZExpbmUoKSApOwogICAgICAgIFN5c3RlbS5vdXQucHJpbnRsbiggc29sdmUoIG4gKSApOwogICAgfQoKICAgIHB1YmxpYyBzdGF0aWMgY2hhciBzb2x2ZSggZmluYWwgbG9uZyBuICkgewogICAgICAgIGlmICggbiA8IDEwICkgewogICAgICAgICAgICByZXR1cm4gKGNoYXIpKCAnMCcgKyBuICk7CiAgICAgICAgfSBlbHNlIHsKICAgICAgICAgICAgcmV0dXJuIHBhcnQoIG4gLSAxMCwgMiApOwogICAgICAgIH0KICAgIH0KCiAgICBwcml2YXRlIHN0YXRpYyBjaGFyIHBhcnQoIGZpbmFsIGxvbmcgbnRoLCBmaW5hbCBpbnQgZGlnQ291bnQgKSB7CiAgICAgICAgaWYgKCBudGggPT0gMCApIHJldHVybiAnMSc7CiAgICAgICAgbG9uZyBwb3cgPSAxOwogICAgICAgIGZvciAoIGludCBpID0gMTsgaSA8IGRpZ0NvdW50OyArK2kgKSB7CiAgICAgICAgICAgIHBvdyAqPSAxMDsKICAgICAgICB9CiAgICAgICAgZmluYWwgbG9uZyBmaXJzdEluUGFydCA9IHBvdzsKICAgICAgICBmaW5hbCBsb25nIHBhcnRTaXplID0gZGlnQ291bnQgKiA5ICogcG93OwogICAgICAgIGlmICggbnRoID4gcGFydFNpemUgKSB7IC8vIHNraXAgdGhhdCBwYXJ0CiAgICAgICAgICAgIHJldHVybiBwYXJ0KCBudGggLSBwYXJ0U2l6ZSwgZGlnQ291bnQgKyAxICk7CiAgICAgICAgfQogICAgICAgIGZpbmFsIGxvbmcgbnVtYmVyID0gbnRoIC8gZGlnQ291bnQ7CiAgICAgICAgZmluYWwgbG9uZyBkaWdpdEluZGV4ID0gbnRoICUgZGlnQ291bnQ7CiAgICAgICAgcmV0dXJuIExvbmcudG9TdHJpbmcoIGZpcnN0SW5QYXJ0ICsgbnVtYmVyICkuY2hhckF0KCAoaW50KWRpZ2l0SW5kZXggKTsKICAgIH0KCn0K