atcoder#ARC123C. [ARC123C] 1, 2, 3 - Decomposition
[ARC123C] 1, 2, 3 - Decomposition
Score : points
Problem Statement
Given is a positive integer . Consider a sequence of integers that satisfies the conditions below:
- ;
- each is a positive integer such that every digit in its decimal notation is , , or .
Find the minimum possible value of , that is, the number of elements in such a sequence .
Process test cases per input file.
Constraints
Input
Input is given from Standard Input in the following format:
Each case is in the following format:
Output
Print the answers.
5
456
10000
123
314
91
2
4
1
2
4
For each , one optimal is shown below.
- For : .
- For : .
- For : .
- For : .
- For : .