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>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

int n;
string s,t;
vector<int> a,b;
vector<int> pa,pb;
int base=5010;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin>>n>>s>>t;
  int p=(s[0]!=t[0]);
  rep(i,base){
    pa.push_back(-1);
    pb.push_back(-1);
  }
  rep(i,n-1){
    a.push_back(s[i]!=s[i+1]);
    if(s[i]!=s[i+1]){
      pa.push_back(i);
    }
    b.push_back(t[i]!=t[i+1]);
    if(t[i]!=t[i+1]){
      pb.push_back(i);
    }
  }
  rep(i,base){
    pa.push_back(n-1);
    pb.push_back(n-1);
  }
  int m1=pa.size(),m2=pb.size();

  ll res=INF;
  for(int i=0;i<m2;i++){
    if((int)abs(i-base)%2!=p)continue;
    int d=i-base;
    ll sum=0;
    rep(j,m1){
      int k=j+d;
      if(k<0||k>=m2)continue;
      sum+=(ll)abs(pa[j]-pb[k]);
    }
    minch(res,sum);
  }
  cout<<res<<endl;

  return 0;
}
