Олимпиадный тренинг

Задача 33550. Short sequence


Задача

Темы:
Given an integer N. Consider the sequence S1S2S3...Sk..., where each group of digits Sk consists of numbers written one after the other from 1 to k. For example, the first 75 digits of the sequence look like this:

112123123412345123456123456712345678123456789123456789101234567891011123456.

It is required to write a program that will determine which digit is in the Nth position in the constructed sequence.

Input
The input contains a single number N (0 < N < 32768).

Imprint
Print the number that is in the Nth position in the sequence.
 
Input Output
3 2
20 5