시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB89549540961.596%

문제

1부터 N까지의 수를 이어서 쓰면 다음과 같이 새로운 하나의 수를 얻을 수 있다.

1234567891011121314151617181920212223...

이렇게 만들어진 새로운 수에서 N이 등장하는 위치를 알고 싶다. 물론 1부터 N까지의 수를 이어 쓰는 것이므로 수의 가장 끝부분에서 N이 항상 등장하게 되지만, 그보다 일찍 등장하는 경우도 있다.

예를 들어 N=151인 경우, 다음과 같이 앞에서 20번째 숫자부터 151이 등장하게 된다.

1234567891011121314151617181920212223...

N이 주어졌을 때, N이 가장 먼저 등장하는 위치를 알아내는 프로그램을 작성하시오.

입력

첫째 줄에 N(1 ≤ N ≤ 100,000)이 주어진다.

출력

첫째 줄에 N이 가장 먼저 등장하는 위치를 출력한다. 앞에서부터 몇 번째인지를 출력하면 된다.

예제 입력 1

15

예제 출력 1

20

예제 입력 2

34

예제 출력 2

3

예제 입력 3

142

예제 출력 3

73
W3sicHJvYmxlbV9pZCI6IjIxNTQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWMyMTggXHVjNzc0XHVjNWI0IFx1YzRmMFx1YWUzMCAzIiwiZGVzY3JpcHRpb24iOiI8cD4xXHViZDgwXHVkMTMwIE5cdWFlNGNcdWM5YzBcdWM3NTggXHVjMjE4XHViOTdjIFx1Yzc3NFx1YzViNFx1YzExYyBcdWM0ZjBcdWJhNzQgXHViMmU0XHVjNzRjXHVhY2ZjIFx1YWMxOVx1Yzc3NCBcdWMwYzhcdWI4NWNcdWM2YjQgXHVkNTU4XHViMDk4XHVjNzU4IFx1YzIxOFx1Yjk3YyBcdWM1YmJcdWM3NDQgXHVjMjE4IFx1Yzc4OFx1YjJlNC48XC9wPlxyXG5cclxuPGJsb2NrcXVvdGU+XHJcbjxwPjEyMzQ1Njc4OTEwMTExMjEzMTQxNTE2MTcxODE5MjAyMTIyMjMuLi48XC9wPlxyXG48XC9ibG9ja3F1b3RlPlxyXG5cclxuPHA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