{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\u003cspan data-preserver-spaces\u003d\"true\"\u003ePandemic mutations represent an excellent topic for scientists. They have discovered a particular molecule that strangely mutates to a string consisting only of $A$\u0026rsquo;s. Scientists also observed that the initial string is a sequence of $N$ characters from the set $\\{ A, B\\}$.\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003e\u003cspan data-preserver-spaces\u003d\"true\"\u003eScientists also observed that there are only two types of mutations. The first mutation changes a single character from the sequence ($A \\rightarrow B$ or $B \\rightarrow A$). Of course, any character can suffer this mutation. The second mutation is more complex, as it changes a whole\u0026nbsp;\u003c/span\u003e\u003cem\u003e\u003cspan data-preserver-spaces\u003d\"true\"\u003eprefix\u003c/span\u003e\u003c/em\u003e\u003cspan data-preserver-spaces\u003d\"true\"\u003e\u0026nbsp;of the sequence, explicitly replacing all characters in positions from $1$ to $K$ (for some $K$ between $1$ and $N$, inclusive) with the other character ($A$ with $B$, $B$ with $A$).\u003c/span\u003e\u003c/p\u003e\n\u003cp\u003e\u003cspan data-preserver-spaces\u003d\"true\"\u003eThe task is to determine the least possible number of mutations that could convert the starting molecule to a state consisting of only $A$ characters. Unluckily, mutations can occur in any order.\u003c/span\u003e\u003c/p\u003e\n\u003ch2\u003eInput\u003c/h2\u003e\n\u003cp\u003e\u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1 \\le N \\le 1\\, 000\\, 000$\u003c/span\u003e) is the length of the molecule and is presenetd on the first line. The second line of input is the starting state of the molecule and\u0026nbsp;contains \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e characters which are either \u003cspan class\u003d\"tex2jax_process\"\u003e$A$\u003c/span\u003e or \u003cspan class\u003d\"tex2jax_process\"\u003e$B$\u003c/span\u003e.\u0026nbsp;\u003c/p\u003e\n\u003ch2\u003eOutput\u003c/h2\u003e\n\u003cp\u003eThe minimum number of mutations.\u003c/p\u003e\n\u003ctable class\u003d\"sample\" summary\u003d\"sample data\"\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003cth\u003eSample Input 1\u003c/th\u003e\n\u003cth\u003eSample Output 1\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cpre\u003e4\nABBA\n\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e2\n\u003c/pre\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003ctable class\u003d\"sample\" summary\u003d\"sample data\"\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003cth\u003eSample Input 2\u003c/th\u003e\n\u003cth\u003eSample Output 2\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cpre\u003e5\nBBABB\n\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e2\n\u003c/pre\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003ctable class\u003d\"sample\" summary\u003d\"sample data\"\u003e\n\u003ctbody\u003e\n\u003ctr\u003e\n\u003cth\u003eSample Input 3\u003c/th\u003e\n\u003cth\u003eSample Output 3\u003c/th\u003e\n\u003c/tr\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cpre\u003e12\nAAABBBAAABBB\n\u003c/pre\u003e\n\u003c/td\u003e\n\u003ctd\u003e\n\u003cpre\u003e4\n\u003c/pre\u003e\n\u003c/td\u003e\n\u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e"}}]}