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<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<queue>
#include<cmath>
#include<vector>
#include<stack>
#include<map>
#include<set>
#define Run(i,l,r) for(int i=l;i<=r;i++)
#define Don(i,l,r) for(int i=l;i>=r;i--)
#define ll long long
#define ld long double
#define inf 0x3f3f3f3f
#define mk make_pair
#define fir first
#define sec second
using namespace std;
const int N=5010;
int n,st1[N],st2[N],tp1,tp2,l1,l2;
char s[N],t[N];
int main(){
//	freopen("E.in","r",stdin);
//	freopen("E.out","w",stdout);
	scanf("%d%s%s",&n,s,t);
	l1=strlen(s),l2=strlen(t);
	for(int i=1;i<l1;i++){
		if(s[i]!=s[i-1])st1[++tp1]=i;
	}
	st1[tp1+1]=n;
	for(int i=1;i<l2;i++){
		if(t[i]!=t[i-1])st2[++tp2]=i;
	} 
	st2[tp2+1]=n;
	int ans = 1e9;
	for(int i=-tp2;i<=tp1+1;i++){
		if((s[0]==t[0])^(!((i-1)&1)))continue;
		int now=0;
		for(int j=-n;j<=n;j++){
			int p1 = min(max(i + j - 1 , 0) , tp1+1 ) , p2 = min(max(j , 0) , tp2+1 );
			now += abs(st1[p1] - st2[p2]);
		}
		ans = min(ans ,now);
	}
	cout<<ans<<endl;
	return 0;
}//by tkys_Austin;
