PivotOJ

1’s For All

시간 제한: 15000ms메모리 제한: 1024MB출처: ICPC ECNA 2021-2022BOJ 24555

문제

The complexity of an integer is the minimum number of 11's needed to represent it using only addition, multiplication and parentheses. For example, the complexity of 22 is 22 (writing 22 as 1+11+1) and the complexity of 1212 is 77 (writing 1212 as (1+1+1)×(1+1+1+1)(1+1+1)\times (1+1+1+1)). We'll modify this definition slightly to allow the concatenation operation as well. This operation (which we'll represent using ©) takes two integers and "glues" them together, so 12 12\ © 34\ 34 becomes the four digit number 12341234. Using this operation, the complexity of 1212 is now 33 (writing it either as (1 (1 \ © 1)+1\ 1) + 1 or 1 1\ © (1+1)\ (1+1)).  Note that the concatenation operation ignores any initial zeroes in the second operand: 1 1\ © 01\ 01 does not result in 101101 but results in 1111.

We'll give you 11 guess what the object of this problem is.

입력

Each test case consists of a single line containing an integer nn, where 0<n1000000 < n \leq 100\, 000.

출력

Output the complexity of the number, using the revised definition above.

예제

예제 1

입력
2
출력
2

예제 2

입력
12
출력
3
코드를 제출하려면 로그인하세요.