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<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
typedef pair<lint,pint> tint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
ostream &operator<<(ostream &os, const vector<int> &a) {
	os<<"[";
	rep(i,a.size()){
		os<<a[i];
		if(i<a.size()-1) os<<",";
	}
	os<<"]";
	return os; 
}
vector<int> v,v2;
#define N 5010
int main()
{
	int n;cin>>n;string s,t;cin>>s;cin>>t;
	rep(i,N+(s[0]-'0')) v.pb(0);
	rep(i,N+(t[0]-'0')) v2.pb(0);
	rep(i,n-1){
		if(s[i]!=s[i+1]) v.pb(i+1);
		if(t[i]!=t[i+1]) v2.pb(i+1);
	}
	//cout<<v<<endl;cout<<v2<<endl;
	int out=1001001001;
	rep(i,N) v.pb(n),v2.pb(n);
	for(int i=0;i<N-2;i+=2){
		int sum=0;
		rep(j,v.size()){
			if(i+j<v2.size()) sum+=abs(v[j]-v2[i+j]);
			else sum+=abs(v[j]-n);
		}
		out=min(out,sum);
	}
	for(int i=0;i<N-2;i+=2){
		int sum=0;
		rep(j,v2.size()){
			if(i+j<v.size()) sum+=abs(v2[j]-v[i+j]);
			else sum+=abs(v2[j]-n);
		}
		out=min(out,sum);
	}
	cout<<out<<endl;
}
