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<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define Fast_IO ios::sync_with_stdio(false);
#define fir first
#define sec second
#define mod 998244353
#define INF 0x3fffffff
#define ll long long
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
typedef pair<int,int> pii;
int add(int x,int y){return x+y>=mod?x+y-mod:x+y;}
int sub(int x,int y){return x-y<0?x-y+mod:x-y;}
int mul(int x,int y){return 1LL*x*y%mod;}
#define N 20005
char s[N],t[N];
int a[N],b[N],ta[N],tb[N];
int c1,c2,n;
signed main()
{
	cin>>n;
	scanf("%s%s",s+1,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;
	// for(int i=1;i<=c1+c2+c2;i++) printf("%d ",a[i]); cout<<"\n";
	int ans=1e9;
	for(int i=0;i<=c2+c1;i+=2)
	{
		for(int j=1;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 R=0;
		// for(int i=1;i<=c1+c2+c2;i++) printf("%d ",b[i]); cout<<"\n";
		for(int j=1;j<=c1+c2+c2;j++) R+=abs(a[j]-b[j]);
		if(R<ans) ans=R;
	}
	cout<<ans<<endl;
	return 0;
}

