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<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
#define fgx cerr<<"--------------"<<endl;
#define dgx cerr<<"=============="<<endl;

inline int read(){
	int x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const int MAXN = 100010;
const int INF = 2147483600;
#define pii pair<int,int> 

int N; char s[MAXN+1],t[MAXN+1]; 
pii sx[MAXN+1],tx[MAXN+1];
int sc=0,tc=0;
#define mp make_pair
#define fr first
#define sn second
LL ret=INF;

inline void solve(){
	t[N+1]='2';
	sc=tc=0; 
	for(int i=0;i<=N;i++){
		if(!i) sx[++sc]=mp(0,(s[1]-'0')^1);
		else if(s[i]!=s[i+1]) sx[++sc]=mp(i,(s[i]-'0'));
	}
	for(int i=0;i<=N;i++){
		if(!i) tx[++tc]=mp(0,(t[1]-'0')^1);
		else if(t[i]!=t[i+1]) tx[++tc]=mp(i,(t[i]-'0'));
	}
	for(int i=1;i<=sc;i++) {
		if(sx[i].sn!=tx[1].sn) continue;
		int nows=i,nowt=1; LL ans=0;
		for(int j=1;j<i;j++) ans+=sx[j].fr;
		while(nowt<=tc&&nows<=sc){
			ans+=abs(tx[nowt].fr-sx[nows].fr);
			++nows; ++nowt;
		}
		while(nows<=sc) ans+=N-sx[nows].fr,++nows;
		while(nowt<=tc) ans+=N-tx[nowt].fr,++nowt;
		ret=min(ret,ans);
	} 
}

int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	N=read(); scanf("%s",s+1); scanf("%s",t+1);
	for(int i=1;i<=N;i++) sc+=(s[i]!=s[i+1]);
	for(int i=1;i<=N;i++) tc+=(t[i]!=t[i+1]);
	if(sc<tc) swap(s,t); solve(); reverse(s+1,s+N+1); reverse(t+1,t+N+1); solve();
	cout<<ret<<endl;
	return 0;
}


