{"trustable":true,"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":"\u003cdiv class\u003d\"panel_content\"\u003e\n 今天是XllX的生日。XllX想和他的好朋友们去烧烤。他们去了一家超市买了很多食物。然后他们骑车去了一个叫老营嘴的地方,那里是一个很好的户外烧烤地点。\n \u003cbr\u003e\n \u003cbr\u003e\n XllX认为一个完美的烧烤串必须满足格式$abba$(就像他的名字一样)。也就是说,一个完美的烧烤串$s$满足$s_i\u003ds_{i+3}$、$s_{i+1}\u003ds_{i+2}$($i \\equiv 1 \\pmod 4$、$len \\equiv 0 \\pmod 4$),索引从$1$开始。注意,空串也是一个完美的串。\n \u003cbr\u003e\n \u003cbr\u003e\n 然而,XllX太忙了,没有准备好烧烤串。它可能不是一个完美的串。现在你可以在1个单位的时间内修改、添加或删除一个字母。你能在最小的时间单位内将烧烤串转变为一个完美的串吗?\n \u003cbr\u003e\n\u003c/div\u003e"}},{"title":"输入","value":{"format":"HTML","content":"每个测试包含多个测试用例。第一行包含测试用例的数量$(1 \\le T \\le 12)$。接下来是测试用例的描述。\n\u003cbr\u003e\n\u003cbr\u003e\n只有一个字符串代表烧烤串。保证字符串的长度不大于$10^6$。字符串中的所有字母均为小写。\n\u003cbr\u003e"}},{"title":"输出","value":{"format":"HTML","content":"对于每个测试用例:\n\u003cbr\u003e\n\u003cbr\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\u003e1\r\nabbba\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}