{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"MD","content":"\u003ccenter\u003e\n### আতা গাছে তোতা পাখি\n### ডালিম গাছে মৌ\n### এতো ডাকি তবু কথা\n### কয়না কেন বউ\n\u003c/center\u003e\n\nMahmud has a special parrot named Rakin that sits on a custard-apple tree all day. As you all know parrots can learn to imitate sound and Rakin is no exception. But it\u0027s capability is limited. It can only say one 3 letters: \u0027`A`\u0027, \u0027`B`\u0027, and \u0027`C`\u0027. Mahmud knows this, so he tries to teach Rakin words consisting of these three letters.\n\nNow what makes Rakin special is whenever Mahmud says any word that contains the substring \u0027`ABC`\u0027, Rakin replaces the substring with \u0027`BCA`\u0027. If the resulting string contains the substring \u0027`ABC`\u0027, Rakin does it again. It continues to perform the same operation until the resulting string does not contain any substring \u0027`ABC`\u0027.\n\nSince Raking is a bird, each replacement takes 1 second. After it is done replacing, it immediately replies with the resulting string. For example: if Mahmud says \u0027`ABCBC`\u0027, Rakin will convert it to \u0027`BCABC`\u0027 in 1 second. Rakin will again convert \u0027`BCABC`\u0027 to \u0027`BCBCA`\u0027 in 1 second. So after 2 seconds, Rakin will reply with \u0027`BCBCA`\u0027 to Mahmud.\n\nMahmud got worried counting how long it will take for his favorite parrot to reply back to him. Help him find the time required so that he can stop talking to the bird and both of them can start learning about contest programming."}},{"title":"Input","value":{"format":"MD","content":"Input consists of a string **S** \u0026mdash; the word Mahmud says to Rakin.\nEach character of **S** is `A`, `B`, or `C`."}},{"title":"Constraints","value":{"format":"MD","content":"- **1 \u0026le; |S| \u0026le; 2 \u0026times; 10\u003csup\u003e5\u003c/sup\u003e**"}},{"title":"Output","value":{"format":"MD","content":"Print an integer denoting the maximum possible seconds required for the parrot to reply."}},{"title":"Sample Input 1","value":{"format":"MD","content":"```\nABCBC\n```"}},{"title":"Sample Output 1","value":{"format":"MD","content":"```\n2\n```"}},{"title":"Sample Input 2","value":{"format":"MD","content":"```\nCB\n```"}},{"title":"Sample Output 2","value":{"format":"MD","content":"```\n0\n```"}},{"title":"Sample Input 3","value":{"format":"MD","content":"```\nABCACCBABCBCAABCB\n```"}},{"title":"Sample Output 3","value":{"format":"MD","content":"```\n6\n```"}}]}