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<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=5000 +117;
const int MM=5000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}


int m,n;
char s[NN]={};
char t[NN]={};
int a[NN]={};
int b[NN]={};
int acnt,bcnt;
int chk(int x){
	int res=0;
	int ap,bp;
	for(int i=min(1,1-x),top=max(acnt,bcnt-x);i<=top;++i){
		if(1<=i&&i<=acnt)ap=a[i];
		if(i<1)ap=1;
		if(i>acnt)ap=n+1;
		int tp=i+x;
		if(1<=tp&&tp<=bcnt)bp=b[tp];
		if(tp<1)bp=1;
		if(tp>bcnt)bp=n+1;
		res+=abs(ap-bp);
	}
	return res;
}
int main(){
	//open();
	n=read();
	scanf("%s",s+1);
	scanf("%s",t+1);
	for(int i=1;i<=n;++i){
		if(s[i]!=s[i-1]){
			a[++acnt]=i;
		}
		if(t[i]!=t[i-1]){
			b[++bcnt]=i;
		}
	}
	int ans=1e9+1;
	int ad=0;
	if(s[1]!=t[1])ad=1;
	int st=-acnt;
	if(ad!=(acnt&1))st-=1;
	for(int i=st;i<=bcnt+1;i+=2){
		ans=min(ans,chk(i));
	}
	printf("%d\n",ans);
	close();
	return 0;
}