By Ygor Ribeiro, IFSULDEMINAS Brazil
Ribeiro, after the defeat of the Brazilian team by 7 x 1 in 2014, has serious problems with these two digits. Now every number he sees, he wants to know how many digits 1 and how many digits 7 appear in all the numbers 1 through N, inclusive.
He knows that you are a great programmer and will help you. To "facilitate" his life, Ribeiro said he wants to know only the sum of the number of digits 1 with the number of digits 7 that appear between all the numbers from 1 to N, inclusive.
For example, think of the number 11: The numbers 1 through 11 are: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11. As we can see the digit 1 appears 4 times, already the digit 7 appears only once. Therefore, the sum of the number of digits 1 and 7 is equal to 5.
You will be given an integer N, you must inform Ribeiro the sum of the number of digits 1 with the number of digits 7 that appear between all the numbers 1 through N.
The input contains an integer N (1 <= N <= 10 ^ 12).
The output should show the sum of the number of digits 1 with the number of digits 7, as it explains the problem.
Input Samples | Output Samples |
11 |
5 |
17 |
12 |
15725 |
18147 |