{"problem":{"name":"AB*A Changing","description":{"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$. You can perform the following operation on $S$ any number of times, possib","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc069_c"},"statements":[{"statement_type":"Markdown","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`.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $S$ and $T$ are strings of length $N$ consisting of `A` and `B`.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$S$\n$T$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc069_c","tags":[],"sample_group":[["5\nAAABA\nBAAAB","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`."],["1\nA\nB","\\-1\n\nIt is impossible to make $S$ equal to $T$. Note that you must choose $(i, j)$ with $i < j$."],["1\nA\nA","0\n\nWithout any operation, $S$ is already equal to $T$."],["10\nAAABBABAAB\nBBABBAAABB","7"]],"created_at":"2026-03-03 11:01:14"}}