#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=5005;
int n,S[N],T[N],ans=1e9;
char s[N],t[N];
void work(int v1,int v2){
	int ans=0;
	For(i,1,v1-1) ans+=S[i];
	For(i,1,v2-1) ans+=T[i];
	for (;v1<=*S&&v2<=*T;v1++,v2++)
		ans+=abs(S[v1]-T[v2]);
	for (;v1<=*S;v1++) ans+=n-S[v1];
	for (;v2<=*T;v2++) ans+=n-T[v2]; 
	::ans=min(::ans,ans);
}
int main(){
	scanf("%d%s%s",&n,s+1,t+1);
	s[0]=97-s[1]; s[n+1]=97-s[n];
	t[0]=97-t[1]; s[n+1]=97-t[n];
	For(i,1,n+1) if (s[i]!=s[i-1]) S[++*S]=i-1;
	For(i,1,n+1) if (t[i]!=t[i-1]) T[++*T]=i-1;
	For(i,1,*S) if (s[S[i]]==t[T[1]]) work(i,1);
	For(i,1,*T) if (s[S[1]]==t[T[i]]) work(1,i);
	printf("%d",ans);
}
### Prompt

In Cpp, your task is to solve the following problem:

You are given strings s and t, both of length N. s and t consist of `0` and `1`. Additionally, in these strings, the same character never occurs three or more times in a row.

You can modify s by repeatedly performing the following operation:

* Choose an index i (1 \leq i \leq N) freely and invert the i-th character in s (that is, replace `0` with `1`, and `1` with `0`), under the condition that the same character would not occur three or more times in a row in s after the operation.



Your objective is to make s equal to t. Find the minimum number of operations required.

Constraints

* 1 \leq N \leq 5000
* The lengths of s and t are both N.
* s and t consists of `0` and `1`.
* In s and t, the same character never occurs three or more times in a row.

Input

Input is given from Standard Input in the following format:


N
s
t


Output

Find the minimum number of operations required to make s equal to t. It can be proved that the objective is always achievable in a finite number of operations.

Examples

Input

4
0011
0101


Output

4


Input

1
0
0


Output

0


Input

8
00110011
10101010


Output

10

### Response

```cpp
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
using namespace std;
const int N=5005;
int n,S[N],T[N],ans=1e9;
char s[N],t[N];
void work(int v1,int v2){
	int ans=0;
	For(i,1,v1-1) ans+=S[i];
	For(i,1,v2-1) ans+=T[i];
	for (;v1<=*S&&v2<=*T;v1++,v2++)
		ans+=abs(S[v1]-T[v2]);
	for (;v1<=*S;v1++) ans+=n-S[v1];
	for (;v2<=*T;v2++) ans+=n-T[v2]; 
	::ans=min(::ans,ans);
}
int main(){
	scanf("%d%s%s",&n,s+1,t+1);
	s[0]=97-s[1]; s[n+1]=97-s[n];
	t[0]=97-t[1]; s[n+1]=97-t[n];
	For(i,1,n+1) if (s[i]!=s[i-1]) S[++*S]=i-1;
	For(i,1,n+1) if (t[i]!=t[i-1]) T[++*T]=i-1;
	For(i,1,*S) if (s[S[i]]==t[T[1]]) work(i,1);
	For(i,1,*T) if (s[S[1]]==t[T[i]]) work(1,i);
	printf("%d",ans);
}
```