Time

18:01:23
22 May 2012
Version for print

Page numbering

  For numbering of M pages in the book N digits were used. By given N output corresponding M or 0, if there is no solution. Numbering starts from first page.


Specifications

   Input

    The only number N. The book is not more than 1001 pages.

   Output

   The desired number of pages.


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 6.66667
Complexity: 34% 380/580
Classes: Simple mathematics

Example

Example input

27

Example output

18


← Median number Problems Game →