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>

const int MAXN = 5010;
int n;
int absx(int x) { return x < 0 ? -x : x; }
char S[MAXN], T[MAXN];
int ax[MAXN], axt[MAXN], ay[MAXN], ayt[MAXN], baka, bakb;
int prea[MAXN], preb[MAXN];
void getmin(int & x, int y) { x > y ? x = y : 0; }

int dp[MAXN][MAXN];
int pre(int typ, int i) { return typ == 0 ? prea[i] : preb[i]; }
int suc(int typ, int i) {
	int res = typ == 0 ? prea[baka] - prea[i - 1] : preb[bakb] - preb[i - 1];
	res = (typ == 0 ? baka - i + 1 : bakb - i + 1) * n - res;
	return res;
}
int main() {
	std::ios_base::sync_with_stdio(false), std::cin.tie(0);
	std::cin >> n >> S + 1 >> T + 1;
	if (n <= 2) {
		int ans = 0;
		for (int i = 1; i <= n; ++i) ans += S[i] != T[i];
		std::cout << ans << std::endl;
		return 0;
	}
	for (int i = 1; i < n; ++i) {
		if (S[i] != S[i + 1]) {
			ax[++baka] = i;
			axt[baka] = S[i] == '1';
		}
		if (T[i] != T[i + 1]) {
			ay[++bakb] = i;
			ayt[bakb] = T[i] == '1';
		}
	}
	for (int i = 1; i <= baka; ++i) prea[i] = prea[i - 1] + ax[i];
	for (int i = 1; i <= bakb; ++i) preb[i] = preb[i - 1] + ay[i];
	int ans = std::numeric_limits<int>::max();
	memset(dp, 0x3f, sizeof dp);
	for (int i = 0; i <= baka; ++i)
		for (int j = 0; j <= bakb; ++j) {
			getmin(dp[i][j], pre(0, i) + pre(1, j));
			getmin(ans, dp[i][j] + suc(0, i + 1) + suc(1, j + 1));
			if (i < baka && j < bakb && axt[i + 1] == ayt[j + 1])
				getmin(dp[i + 1][j + 1], dp[i][j] + absx(ax[i + 1] - ay[j + 1]));
		}
	std::cout << ans << std::endl;
	return 0;
}
