{"raw_statement":[{"iden":"problem statement","content":"You are given two strings $S$ and $T$ of length $N$ consisting of `A` and `B`. Let $s_i$ denote the $i$\\-th character of $S$.\nYou can perform the following operation on $S$ any number of times, possibly zero:\n\n*   Choose an integer pair $(i, j)$ satisfying the following conditions:\n    *   $1 \\leq i < j \\leq N$\n    *   $s_i = s_j = $ `A`\n    *   $s_{i+1} = s_{i+2} = \\ldots = s_{j-1} = $ `B`\n*   Then, simultaneously replace each of $s_i, s_{i+1}, \\ldots, s_j$ with the other character (`A` becomes `B`, and `B` becomes `A`).\n\nDetermine the minimum number of operations required to make $S$ equal to $T$. If it is impossible, print `-1`."},{"iden":"constraints","content":"*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $S$ and $T$ are strings of length $N$ consisting of `A` and `B`."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$\n$S$\n$T$"},{"iden":"sample input 1","content":"5\nAAABA\nBAAAB"},{"iden":"sample output 1","content":"2\n\nYou can make $S$ equal to $T$ in two operations as follows:\n\n1.  Perform the operation with $(i, j) = (2, 3)$. $S$ becomes `ABBBA`.\n2.  Perform the operation with $(i, j) = (1, 5)$. $S$ becomes `BAAAB`.\n\nIt is impossible to make $S$ equal to $T$ in fewer than two operations, so the answer is `2`."},{"iden":"sample input 2","content":"1\nA\nB"},{"iden":"sample output 2","content":"\\-1\n\nIt is impossible to make $S$ equal to $T$. Note that you must choose $(i, j)$ with $i < j$."},{"iden":"sample input 3","content":"1\nA\nA"},{"iden":"sample output 3","content":"0\n\nWithout any operation, $S$ is already equal to $T$."},{"iden":"sample input 4","content":"10\nAAABBABAAB\nBBABBAAABB"},{"iden":"sample output 4","content":"7"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}