{"trustable":true,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027$$$$$$\u0027, right: \u0027$$$$$$\u0027, display: true},\n {left: \u0027$$$\u0027, right: \u0027$$$\u0027, display: false},\n {left: \u0027$$\u0027, right: \u0027$$\u0027, display: true},\n {left: \u0027$\u0027, right: \u0027$\u0027, display: false}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eOur best explorer, Vingying, finds a deep cave that is full of diamonds! Well, he is a very careful man, so he decides to do some research before collecting them.\u003c/p\u003e\u003cp\u003eThe diamonds can be divided into three kinds, noted as $$$\\text{A,B,C}$$$ for convenience. There are a total of $$$n$$$ diamonds in a row, which can be regarded as a sequence $$$s_1,s_2,\\dots,s_n$$$ from left to right. Vingying will perform the operation several times, which consists of the following three steps in order.\u003c/p\u003e\u003col\u003e \u003cli\u003e Choose an index $$$i$$$ ($$$1\\le i \\le n - 2$$$) satisfying $$$s_i \u003d \\text{A}$$$, $$$s_{i+1}\u003d\\text{B}$$$, $$$s_{i+2}\u003d\\text{C}$$$. \u003c/li\u003e\u003cli\u003e If the index is odd, then collect $$$s_i$$$ and $$$s_{i+2}$$$; otherwise, collect $$$s_{i+1}$$$. \u003c/li\u003e\u003cli\u003e Update $$$n$$$ to the number of diamonds left and reindex the diamonds. \u003c/li\u003e\u003c/ol\u003e\u003cp\u003eFor example, $$$s\u003d\\text{ABCABC}$$$. We can choose index $$$1$$$ and collect $$$1,3$$$, then $$$s$$$ becomes $$$\\text{BABC}$$$ indexed $$$1,2,3,4$$$. But if we choose index $$$4$$$ and collect $$$5$$$, then $$$s$$$ becomes $$$\\text{ABCAC}$$$ indexed $$$1,2,3,4,5$$$.\u003c/p\u003e\u003cp\u003eVingying wants to know the maximum number of \u003cspan class\u003d\"tex-font-style-bf\"\u003eoperations\u003c/span\u003e (not the diamonds) he can do.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe input contains a string consisting of only $$$\\text{A,B,C}$$$ representing the sequence of the diamonds. The length of the string won\u0027t exceed $$$2\\times10^5$$$.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003eOutput a single integer representing the maximum number of \u003cspan class\u003d\"tex-font-style-bf\"\u003eoperations\u003c/span\u003e.\u003c/p\u003e"}},{"title":"Examples","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eABCAAABCCC\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003eAABCAAABCCC\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e4\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}