{"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\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 type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003eThe string $$$t_1t_2 \\dots t_k$$$ is good if each letter of this string belongs to at least one palindrome of length \u003cspan class\u003d\"tex-font-style-bf\"\u003egreater\u003c/span\u003e than \u003cspan class\u003d\"tex-font-style-tt\"\u003e1\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eA palindrome is a string that reads the same backward as forward. For example, the strings \u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eBAB\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eABBA\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eBAABBBAAB\u003c/span\u003e are palindromes, but the strings \u003cspan class\u003d\"tex-font-style-tt\"\u003eAB\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eABBBAA\u003c/span\u003e, \u003cspan class\u003d\"tex-font-style-tt\"\u003eBBBA\u003c/span\u003e are not.\u003c/p\u003e\u003cp\u003eHere are some examples of good strings: \u003c/p\u003e\u003cul\u003e \u003cli\u003e $$$t$$$ \u003d \u003cspan class\u003d\"tex-font-style-tt\"\u003eAABBB\u003c/span\u003e (letters $$$t_1$$$, $$$t_2$$$ belong to palindrome $$$t_1 \\dots t_2$$$ and letters $$$t_3$$$, $$$t_4$$$, $$$t_5$$$ belong to palindrome $$$t_3 \\dots t_5$$$); \u003c/li\u003e\u003cli\u003e $$$t$$$ \u003d \u003cspan class\u003d\"tex-font-style-tt\"\u003eABAA\u003c/span\u003e (letters $$$t_1$$$, $$$t_2$$$, $$$t_3$$$ belong to palindrome $$$t_1 \\dots t_3$$$ and letter $$$t_4$$$ belongs to palindrome $$$t_3 \\dots t_4$$$); \u003c/li\u003e\u003cli\u003e $$$t$$$ \u003d \u003cspan class\u003d\"tex-font-style-tt\"\u003eAAAAA\u003c/span\u003e (all letters belong to palindrome $$$t_1 \\dots t_5$$$); \u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou are given a string $$$s$$$ of length $$$n$$$, consisting of \u003cspan class\u003d\"tex-font-style-bf\"\u003eonly\u003c/span\u003e letters \u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e.\u003c/p\u003e\u003cp\u003eYou have to calculate the number of good substrings of string $$$s$$$.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003eThe first line contains one integer $$$n$$$ ($$$1 \\le n \\le 3 \\cdot 10^5$$$) — the length of the string $$$s$$$.\u003c/p\u003e\u003cp\u003eThe second line contains the string $$$s$$$, consisting of letters \u003cspan class\u003d\"tex-font-style-tt\"\u003eA\u003c/span\u003e and \u003cspan class\u003d\"tex-font-style-tt\"\u003eB\u003c/span\u003e.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003ePrint one integer — the number of good substrings of string $$$s$$$.\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\u003e5\nAABBB\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e6\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\u003e3\nAAA\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e3\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\u003e7\nAAABABB\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e15\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}},{"title":"Note","value":{"format":"HTML","content":"\u003cp\u003eIn the first test case there are six good substrings: $$$s_1 \\dots s_2$$$, $$$s_1 \\dots s_4$$$, $$$s_1 \\dots s_5$$$, $$$s_3 \\dots s_4$$$, $$$s_3 \\dots s_5$$$ and $$$s_4 \\dots s_5$$$.\u003c/p\u003e\u003cp\u003eIn the second test case there are three good substrings: $$$s_1 \\dots s_2$$$, $$$s_1 \\dots s_3$$$ and $$$s_2 \\dots s_3$$$.\u003c/p\u003e"}}]}