#K34032. Minimum Digit Word Reconstruction

    ID: 25219 Type: Default 1000ms 256MiB

Minimum Digit Word Reconstruction

Minimum Digit Word Reconstruction

Given a string \(S\) composed of characters, each character is expected to be a digit between 0 and 9. Each digit \(d\) can be uniquely transformed into its corresponding English word \(w(d)\) according to the following mapping:

[ \begin{array}{c|c} \text{Digit} & \text{Word} \ \hline 0 & \text{zero} \ 1 & \text{one} \ 2 & \text{two} \ 3 & \text{three} \ 4 & \text{four} \ 5 & \text{five} \ 6 & \text{six} \ 7 & \text{seven} \ 8 & \text{eight} \ 9 & \text{nine} \end{array} ]

Your task is to determine the minimum number of words required to reconstruct the string \(S\) by considering a one-to-one mapping for each digit. In other words, if each character in \(S\) is valid (i.e. a digit between 0 and 9), the answer is simply the length of \(S\). If any character in \(S\) does not have a corresponding mapping (i.e. is not a digit), the output should be \(-1\).

Note: The input is given via standard input and the output should be written to standard output.

inputFormat

The input consists of a single line containing the string \(S\). \(S\) is expected to contain only characters and its length can be determined by \(|S|\).

outputFormat

Output a single integer representing the minimum number of words required to reconstruct the string if every character in \(S\) can be mapped (which is \(|S|\)); otherwise, output \(-1\) if there exists any character that does not have a corresponding digit-to-word mapping.

## sample
12345
5