|
||||||||||
InvokerTime Limit: 15000/12000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2144 Accepted Submission(s): 644 Problem Description In dota2, there is a hero named Invoker. He has 3 basic skills in the game, which are Quas, Wex and Exort. Once he launches a basic skill, he will gain the corresponding element, where Quas gives "Q", Wex gives "W" and Exort gives "E". Invoker can't have more than 3 elements simultaneously. If he launches a basic skill when he already owns 3 elements, he will get the corresponding element and lose the element he gained the earliest. As can be seen, there are 10 unordered combinations of 3 elements in 3 types, each represents a special skill, which are as follows: When Invoker owns 3 elements, he can launch the invoking skill, denoted by "R", to gain the special skill according to the elements he currently owns. After invoking, the elements won't disappear, and the chronological order of the 3 elements won't change. Now given a sequence of special skills, you want to invoke them one by one with using the minimum number of basic skills(Q,W,E) and invoking skill(R). Print the minimum number in a single line. At the beginning, Invoker owns no elements. And you should re-invoke the special skills even if you have already invoked the same skills just now. Input Input a single line containing a string s (1 ¡Ü |s| ¡Ü 100 000) that only contains uppercase letters in {B, C, D, F, G, T, V, X, Y, Z}, denoting the sequence of special skills. Output Output a single line containing a positive integer, denoting the minimum number of skills to launch. Sample Input
Sample Output
Hint One possible scheme is QWWREERERWQRQRR. Source | ||||||||||
|