A. Monodigit

Memory limit: 256 MiB Time limit: 1000 ms Input file: stdin Output file: stdout
Problem type: traditional Judging mode: text compare

Description

愛麗絲喜歡數字,尤其是獨位數。如果一個正整數只包含一種數位,愛麗絲便稱它為獨位數。舉例來説, 11111 777777 3 是獨位數,而 10 57775 888880 不是獨位數。

現在,愛麗絲想知道在 1 N 之間(含)有多少個獨位數。你能幫她計算嗎?


Alice loves numbers, especially monodigit numbers. She calls a positive integer monodigit if and only if the integer contains exactly one type of digit. For example, 11111 , 777777 and 3 are monodigit numbers, while 10 , 57775 , 888880 are not.

Now, she wants to count the number of monodigit integers from 1 to N (inclusive). Can you help her?

Input

輸入只有一個正整數, N


The input consists of only one integer N .

Output

輸出一個正整數, 1 N 之間(含)獨位數的數量。


Output exactly one positive integer, the number of monodigit integers from 1 to N (inclusive).

Sample

Sample input

100

Sample output

18

Constraint and hint

對於全部測試數據,滿足 1 \leq N \leq 10^9

子任務 分數 附加限制
1 20 N \leq 10
2 45 N \leq 10^6
4 35 無附加限制

For all test data, 1 \leq N \leq 10^9 .

Subtask Score Additional Constraints
1 20 N \leq 10
2 45 N \leq 10^6
4 35 No additional constraints