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
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cmath>
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;
char s[20005],t[20005];
int a[20005],b[20005],ta[20005],tb[20005];
int c1,c2,n;
int read()
{
	char c=getchar();
	int res=0;
	while(c<'0'||c>'9') c=getchar();
	while(c>='0'&&c<='9') res=(res<<1)+(res<<3)+(c^48),c=getchar();
	return res;
}
int main()
{
	n=read();
	scanf("%s",s+1);scanf("%s",t+1);
	if(s[1]=='1') ta[++c1]=0;
	for(int i=1;i<n;i++) if(s[i]!=s[i+1]) ta[++c1]=i;
	if(s[n]=='1') ta[++c1]=n;
	if(t[1]=='1') tb[++c2]=0;
	for(int i=1;i<n;i++) if(t[i]!=t[i+1]) tb[++c2]=i;
	if(t[n]=='1') tb[++c2]=n;
	for(int i=1;i<=c1;i++) a[i+c2]=ta[i];
	for(int i=c1+c2+1;i<=c1+c2+c2;i++) a[i]=n;
	int ans=0x3f3f3f3f;
	for(int i=0;i<=c1+c2;i+=2)
	{
		for(int j=0;j<=i;j++) b[j]=0;
		for(int j=1;j<=c2;j++) b[i+j]=tb[j];
		for(int j=i+c2+1;j<=c1+c2+c2;j++) b[j]=n;
		int sum=0;
		for(int j=0;j<=c1+c2+c2;j++) sum+=abs(a[j]-b[j]);
		ans=min(ans,sum);
	}
	printf("%d\n",ans);
}