LearnPy Hub
← Arena
IntermediateRating 1450

How Many 1s?

Count how many times the digit 1 appears when you write all numbers from 1 to n.

Input

One integer n (0 ≤ n ≤ 10¹⁵).

Output

One integer.

Sample 1

Input
13
Output
6

Sample 2

Input
0
Output
0
solution.py
Output appears here
How Many 1s? · Python Arena problem · LearnPy Hub