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
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-03-24 16:15:40
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=5010;
int n,a[N],A,b[N],B,ans;
char s[N],c[N];
int main()
{
	n=read();
	scanf("%s%s",s+1,c+1);
	if(s[1]=='1') a[A=1]=0;
	if(c[1]=='1') b[B=1]=0;
	fr(i,2,n) if(s[i]!=s[i-1]) a[++A]=i-1;
	fr(i,2,n) if(c[i]!=c[i-1]) b[++B]=i-1;
//	fr(i,1,A) printf("%d%c",a[i],i==A?'\n':' ');
//	fr(i,1,B) printf("%d%c",b[i],i==B?'\n':' ');
	ans=1<<29;
	fr(d,-n-1,n+1) if(!(d&1))
	{
		int x=1,y=1,Ans=0;
		if(d<0) x-=std::abs(d);
		else y-=std::abs(d);
		while(x<=n||y<=n)
		{
//			printf(" %d %d  %d\n",x,y,std::abs((x<=0?0:x>A?n:a[x])-(y<=0?0:y>B?n:b[y])));
			Ans+=std::abs((x<=0?0:x>A?n:a[x])-(y<=0?0:y>B?n:b[y])); x++; y++;
		}
//		printf("%d %d\n",d,Ans);
		ans=std::min(ans,Ans);
	}
	printf("%d\n",ans);
	return 0;
}