#AGC052E. [AGC052E] 3 Letters

[AGC052E] 3 Letters

Score : 15001500 points

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 SS and TT of length NN. In one operation, you can choose any letter of SS, and change it to another letter among A, B, and C, so that SS remains good.

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

Constraints

  • 1N51051\le N \le 5\cdot 10^5
  • SS is a good string of length NN consisting of A, B, and C
  • TT is a good string of length NN consisting of A, B, and C

Input

Input is given from Standard Input in the following format:

NN

SS

TT

Output

Output the smallest number of operations needed to transform SS into TT.

4
CABC
CBAC
6

Here is one possible sequence of operations of length 66:

CABC \to BABC \to BCBC \to BCAC \to ACAC \to ABAC \to CBAC

It can be shown that 66 operations are necessary for this case.

10
ABABABABAB
BABABABABA
15