{"trustable":false,"prependHtml":"\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\" type\u003d\"text/javascript\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cscript type\u003d\u0027text/x-mathjax-config\u0027\u003eMathJax.Hub.Config({tex2jax: { inlineMath: [[\u0027$\u0027,\u0027$\u0027]] } }); \u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027 src\u003d\u0027https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config\u003dTeX-AMS-MML_HTMLorMML\u0027\u003e\u003c/script\u003e\n\u003cscript type\u003d\u0027text/javascript\u0027\u003esetTimeout(function(){MathJax.Hub.Queue([\u0027Typeset\u0027, MathJax.Hub, \u0027left_view\u0027]);}, 2000);\u003c/script\u003e\n\u003cdiv class\u003d\"panel_content\"\u003e\n Sister Qin likes to play Dota2, and she also like a hero called Invoker. The man is the only one that Sister Qin wanna practise. 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\". \n \u003cbr\u003eInvoker can\u0027t 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. \n \u003cbr\u003eAs can be seen, there are 10 unordered combinations of 3 elements in 3 types, each represents a special skill, which are as follows: \n \u003cbr\u003e \n \u003cbr\u003e \n \u003cli\u003e Cold Snap: unordered element combination \"QQQ\", denoted by \"Y\"\u003c/li\u003e \n \u003cbr\u003e \n \u003cli\u003e Ghost Walk: unordered element combination \"QQW\", denoted by \"V\"\u003c/li\u003e \n \u003cbr\u003e \n \u003cli\u003e Ice Wall: unordered element combination \"QQE\", denoted by \"G\"\u003c/li\u003e \n \u003cbr\u003e \n \u003cli\u003e EMP: unordered element combination \"WWW\", denoted by \"C\"\u003c/li\u003e \n \u003cbr\u003e \n \u003cli\u003e Tornado: unordered element combination \"QWW\", denoted by \"X\"\u003c/li\u003e \n \u003cbr\u003e \n \u003cli\u003e Alacrity: unordered element combination \"WWE\", denoted by \"Z\"\u003c/li\u003e \n \u003cbr\u003e \n \u003cli\u003e Sun Strike: unordered element combination \"EEE\", denoted by \"T\"\u003c/li\u003e \n \u003cbr\u003e \n \u003cli\u003e Forge Spirit: unordered element combination \"QEE\", denoted by \"F\"\u003c/li\u003e \n \u003cbr\u003e \n \u003cli\u003e Chaos Meteor: unordered element combination \"WEE\", denoted by \"D\"\u003c/li\u003e \n \u003cli\u003e Deafening Blast: unordered element combination \"QWE\", denoted by \"B\"\u003c/li\u003e \n \u003cbr\u003eWhen 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\u0027t disappear, and the chronological order of the 3 elements won\u0027t change. \n \u003cbr\u003eNow 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. \n \u003cbr\u003eAt 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. \n\u003c/div\u003e"}},{"title":"Input","value":{"format":"HTML","content":"(需要多组输入)\nInput 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."}},{"title":"Output","value":{"format":"HTML","content":"Output a single line containing a positive integer, denoting the minimum number of skills to launch."}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003eXDTBVV\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e15\n\n \n \u003ci style\u003d\"font-size:1px\"\u003e \u003c/i\u003e\u003c/pre\u003e"}},{"title":"Hint","value":{"format":"HTML","content":"\u003cpre\u003e\nOne possible scheme is QWWREERERWQRQRR.\n\n \n \u003c/pre\u003e"}}]}