#agc049b. [agc049_b]Flip Digits

[agc049_b]Flip Digits

Problem Statement

Given are length-NN strings SS and TT consisting of 0 and 1. You can do the following operation on SS any number of times:

  • Choose ii (2leqileqN2 \\leq i \\leq N) such that Si=S_i=1, and replace SiS_i with 0. Additionally, invert Si1S_{i-1}, that is, change it to 1 if it is 0 now and vice versa.

Is it possible to make SS exactly match TT? If it is possible, how many operations does it take at least?

Constraints

  • 1leqNleq5times1051 \\leq N \\leq 5 \\times 10^5
  • SS is a string of length NN consisting of 0 and 1.
  • TT is a string of length NN consisting of 0 and 1.

Input

Input is given from Standard Input in the following format:

NN SS TT

Output

If it is possible to make SS exactly match TT, print the minimum number of operations it takes. Otherwise, print \-1\-1.


Sample Input 1

3
001
100

Sample Output 1

2

We can do as follows: 001 → (choose i=3i=3) → 010 → (choose i=2i=2) → 100.


Sample Input 2

3
001
110

Sample Output 2

-1

Sample Input 3

5
10111
01010

Sample Output 3

5