AtCoder Grand Contest 052
E
3 Letters
AtCoder
⌀ 3457
原题
← DF →
翻译中…

Problem Statement

翻译中…

A string, consisting of letters A, B, and C, is called good, if every two consecutive letters are different. For example, strings ABABAB and ABC are good, while ABBA and AABBCC aren't.

翻译中…

You are given two good strings $S$ and $T$ of length $N$. In one operation, you can choose any letter of $S$, and change it to another letter among A, B, and C, so that $S$ remains good.

翻译中…

What's the smallest number of operations needed to transform $S$ into $T$? We can prove that it can always be done in a finite number of operations.

翻译中…

Constraints

翻译中…
  • $1\le N \le 5\cdot 10^5$
  • $S$ is a good string of length $N$ consisting of A, B, and C
  • $T$ is a good string of length $N$ consisting of A, B, and C
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
S
T

翻译中…

Output

翻译中…

Output the smallest number of operations needed to transform $S$ into $T$.

翻译中…

样例

Input #1
4
CABC
CBAC
Output #1
6
Here is one possible sequence of operations of length $6$: `CABC` $\to$ `BABC` $\to$ `BCBC` $\to$ `BCAC` $\to$ `ACAC` $\to$ `ABAC` $\to$ `CBAC` It can be shown that $6$ operations are necessary for this case.
Input #2
10
ABABABABAB
BABABABABA
Output #2
15
题目信息
题号
agc052_e
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。