Inversions in Lexicographical Order

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

An inversion in permutation p=p_1,p_2,,p_np = \langle p\_1, p\_2, \ldots, p\_n \rangle is a pair of integers (i,j)(i, j) such that i<ji < j and p_i>p_jp\_i > p\_j.

Consider a lexicographical order on positive integers. Under this ordering, integers are compared lexicographically as strings of digits. For example, 628 comes before 7, 239 comes before 271, and 42 comes before 427.

You are given a single positive integer nn. Let's sort all integers from 1 to nn, inclusive, in lexicographical order. We'll get a permutation pp of length nn, where p_1p\_1 is the lexicographically smallest integer between 1 and nn (actually, p_1=1p\_1 = 1 for any nn), p_2p\_2 is the second smallest one, and so on.

How many inversions does pp contain?

입력

The only line of the input contains a single positive integer nn without leading zeroes.

The value of nn will be between 1 and 10250,000110^{250\\,000} - 1, inclusive. That is, nn will consist of no more than 250,000250\\,000 decimal digits.

출력

Output a single integer without leading zeroes --- the number of inversions in pp.

힌트

Indeed, in the first example test case, p=1,10,11,2,3,4,5,6,7,8,9p = \langle 1, 10, 11, 2, 3, 4, 5, 6, 7, 8, 9 \rangle contains 16 inversions.