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;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
string S,T;

vector<int> A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>S>>T;
	
	if(N<3) {
		int ret=0;
		FOR(i,N) ret+=S[i]!=T[i];
		cout<<ret<<endl;
		return;
	}
	
	if(S[0]=='1') A.push_back(0);
	if(T[0]=='1') B.push_back(0);
	for(i=1;i<N;i++) {
		if(S[i]!=S[i-1]) A.push_back(i);
		if(T[i]!=T[i-1]) B.push_back(i);
	}
	
	int mi=1<<30;
	for(int D=-(N+2);D<=N+2;D++) if(D%2==0) {
		int tot=0;
		FOR(i,A.size()) {
			y=i+D;
			if(y<0) r=0;
			else if(y>=B.size()) r=N;
			else r=B[y];
			tot+=abs(A[i]-r);
		}
		FOR(i,B.size()) {
			y=i-D;
			if(y>=0 && y<A.size()) continue;
			if(y<0) r=0;
			else r=N;
			tot+=abs(B[i]-r);
		}
		
		mi=min(mi,tot);
	}
	
	cout<<mi<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
