#P10571. [JRKSJ R8] 三七二十一
[JRKSJ R8] 三七二十一
Problem Description
You are given a digit string consisting of digits from . Define the number represented by a digit string as the decimal value obtained by treating it as a base-10 number. Formally, for a digit string of length , the represented number is .
You may perform several operations on this digit string. In each operation, you can choose a position and change to any digit from . You need to make sure that this digit string has no non-empty substring whose represented number is , i.e., any non-negative integer power of . Please find the minimum number of operations.
Input Format
One line containing a digit string .
Output Format
One line containing an integer representing the answer.
2468
3
164
2
65535
0
Hint
Sample Explanation
For sample , the non-empty substrings of whose represented numbers are non-negative integer powers of are . Changing to is one of the optimal solutions.
For sample , the non-empty substrings of whose represented numbers are non-negative integer powers of are . Changing to is one of the optimal solutions.
Constraints
This problem uses bundled testdata.
Let .
| Score | ||
|---|---|---|
For of the testdata, , and consists of digits from .
Translated by ChatGPT 5