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 <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXN=5000;

int n;
char s[MAXN+1];
char t[MAXN+1];

vector<int> a;
vector<int> b;

int solve() {
	b.clear(); if(t[0]=='1') b.PB(0); FOR(i,1,n) if(t[i]!=t[i-1]) b.PB(i); if(SZ(b)%2!=1) b.PB(n);
	int nextra=(SZ(b)+1)/2*2; a.clear(); REP(i,nextra) a.PB(0); if(s[0]=='1') a.PB(0); FOR(i,1,n) if(s[i]!=s[i-1]) a.PB(i); if(SZ(a)%2!=1) a.PB(n); REP(i,nextra) a.PB(n);
	//printf("a:"); REPSZ(i,a) printf(" %d",a[i]); puts("");
	//printf("b:"); REPSZ(i,b) printf(" %d",b[i]); puts("");
	int ret=INT_MAX;
	REPE(offset,SZ(a)-SZ(b)) if(offset%2==0) {
		int cur=0;
		REPSZ(i,a) if(i<offset) cur+=abs(a[i]-0); else if(i<offset+SZ(b)) cur+=abs(a[i]-b[i-offset]); else cur+=abs(a[i]-n);
		//printf("%d:",offset); REPSZ(i,b) printf(" %d",a[offset+i]); printf(" -> %d\n",cur);
		ret=min(ret,cur);
	}
	return ret;
}

void run() {
	scanf("%d",&n); scanf("%s",s); scanf("%s",t);
	printf("%d\n",solve());
}

int main() {
	run();
	return 0;
}
