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<cstring>
#include<cmath>
#include<algorithm>
#include<iterator>
#include<cstdlib>
#include<vector>
#define fst first
#define snd second
using namespace std;
typedef long long ll;
typedef ostream_iterator<int> os_iter_int;

int n;
bool s[10010],t[10010];
vector<pair<int,int>> l1,l2;

template<typename inp_t>
void readx(inp_t& x)
{
	x=0; int k=1; char ch=0;
	while (ch<'0' || ch>'9') { ch=getchar(); if (ch=='-') k=-1; }
	while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	x*=k;
}

void Make(bool* seq,vector<pair<int,int>>& vec)
{
	int fi=0;
	for (int i=1;i<n;i++) if (seq[i]!=seq[i+1])
	{
		if (!fi)
		{
			fi=1;
			for (int j=1;j<=n;j++) vec.push_back(make_pair(0,j%2));
			if (seq[i]==vec.back().snd) vec.push_back(make_pair(0,s[i]^1));
		}
		vec.push_back(make_pair(i,seq[i]));
	}
	for (int i=1;i<=n;i++) vec.push_back(make_pair(n,(vec.back().snd)^1));
}

int main()
{
	readx(n); char ch=0;
	for (int i=1;i<=n;i++)
	{
		ch=0; while (ch<'0' || ch>'1') ch=getchar();
		s[i]=ch-'0';
	}
	for (int i=1;i<=n;i++)
	{
		ch=0; while (ch<'0' || ch>'1') ch=getchar();
		t[i]=ch-'0';
	}
	
	if (n<=2)
	{
		if (n==1) printf("%d\n",(t[1]==s[1])^1);
		else printf("%d\n",((t[1]==s[1])^1)+((t[2]==s[2])^1));
		return 0;
	}
	
	// make lines
	Make(s,l1); Make(t,l2);
	
	int ans=n*n*2,l1pos=0;
	for (unsigned i=0;i<l1.size();i++) 
		if (l1[i].fst>0) { l1pos=i; break; }
	
	for (unsigned i=0;i<l2.size()-n+1;i++) if (l2[i].snd==l1[l1pos].snd)
	{
		int tmp=0;
		int s1=l1pos,s2=i;
		while (s1 && s2) { s1--; s2--; }
		while (s1<l1.size() && s2<l2.size())
		{
			tmp+=abs(l1[s1].fst-l2[s2].fst);
			s1++; s2++;
		}
		ans=min(ans,tmp);
	}
	
	printf("%d\n",ans);
}