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<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
char S[5011], T[5011];

void MAIN() {
    scanf("%d", &N);
    scanf("%s%s", S, T);

    LL ans = 1<<29;
    REP (t, 2) {
	int x = (S[0] != T[0]);
	for (int a=x; a<=N; a+=2) {
	    int pos = -1, pool = a;
	    LL tmp = 0;
	    REP (i, N-1) {
		if (S[i] == S[i+1]) {
		    while (pos < N-1 && pool == 0) {
			pos++;
			if (pos < N-1 && T[pos] == T[pos+1]) pool = 1;
		    }

		    tmp += abs(i - pos);
		    pool--;
		}
	    }
	    while (pos < N-1) {
		while (pool) {
		    tmp += abs(N-1 - pos);
		    pool--;
		}
		pos++;
		if (pos < N-1 && T[pos] == T[pos+1]) pool = 1;
	    }
	    amin(ans, tmp);
	}
	REP (i, N) swap(S[i], T[i]);
    }
    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}

