Naman has two binary strings s and t of length n (a binary string is a string which only consists of the characters "0" and "1"). He wants to convert s into t using the following operation as few times as possible.

In one operation, he can choose any subsequence of s and rotate it clockwise once.

For example, if s = 1110100, he can choose a subsequence corresponding to indices (1-based) \{2, 6, 7 \} and rotate them clockwise. The resulting string would then be s = 1010110.

A string a is said to be a subsequence of string b if a can be obtained from b by deleting some characters without changing the ordering of the remaining characters.

To perform a clockwise rotation on a sequence c of size k is to perform an operation which sets c_1:=c_k, c_2:=c_1, c_3:=c_2, …, c_k:=c_{k-1} simultaneously.

Determine the minimum number of operations Naman has to perform to convert s into t or say that it is impossible. 

Input

The first line contains a single integer n (1 ≤ n ≤ 10^6) — the length of the strings.

The second line contains the binary string s of length n.

The third line contains the binary string t of length n.

Output

If it is impossible to convert s to t after any number of operations, print -1.

Otherwise, print the minimum number of operations required.

Examples

Input


6
010000
000001


Output


1

Input


10
1111100000
0000011111


Output


5

Input


8
10101010
01010101


Output


1

Input


10
1111100000
1111100001


Output


-1

Note

In the first test, Naman can choose the subsequence corresponding to indices \{2, 6\} and rotate it once to convert s into t.

In the second test, he can rotate the subsequence corresponding to all indices 5 times. It can be proved, that it is the minimum required number of operations.

In the last test, it is impossible to convert s into t.
#include <bits/stdc++.h>
using namespace std;
vector<long long int> fact(500005);
long long int modInverse(long long int a, long long int m) {
  long long int mom = m, y = 0, x = 1;
  if (m == 1) return 0;
  while (a > 1) {
    long long int q = a / m;
    long long int top = m;
    m = a % m;
    a = top;
    top = y;
    y = x - q * y;
    x = top;
  }
  if (x < 0) x += mom;
  return x % 1000000007;
}
long long int power(long long int x, long long int y, long long int p) {
  long long int res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res % p;
}
vector<long long int> getAllFactors(long long int n) {
  vector<long long int> v;
  for (long long int i = 2; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i)
        v.push_back(i);
      else {
        v.push_back(i);
        v.push_back(n / i);
      }
    }
  }
  return v;
}
inline bool isVowel(char c) {
  if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u' || c == 'A' ||
      c == 'E' || c == 'I' || c == 'O' || c == 'U')
    return true;
  else
    return false;
}
inline bool isPowerOfTwo(long long int x) { return x && (!(x & (x - 1))); }
bool isPrime(long long int n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long int i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
inline void preComputeFactorial() {
  fact[0] = 1;
  for (long long int i = 1; i <= 500005; i++)
    fact[i] = (fact[i - 1] % 1000000007 * i % 1000000007) % 1000000007;
}
long long int gcd(long long int a, long long int b) {
  if (a == 0) return b;
  if (b == 0) return a;
  if (a == b) return a;
  if (a > b) return gcd(a - b, b);
  return gcd(a, b - a);
}
long long int computeXOR(long long int n) {
  if (n % 4 == 0) return n;
  if (n % 4 == 1) return 1;
  if (n % 4 == 2)
    return n + 1;
  else
    return 0;
}
long long int setBitNumber(long long int n) {
  long long int k = (long long int)(log2(n));
  return (long long int)(pow(2, k));
}
long long int task(long long int n, string s, string t) {
  if (s == t) return 0;
  if (count(s.begin(), s.end(), '1') == 1) return 1;
  set<long long int> alpha, beta, gamma;
  for (long long int i = 0; i <= n - 1; i++) {
    if (s[i] != t[i]) {
      if (s[i] == '0')
        alpha.insert(i);
      else
        beta.insert(i);
      gamma.insert(i);
    }
  }
  long long int result = 0;
  while (alpha.size() && beta.size()) {
    long long int id = *gamma.begin(), flag = 0, e;
    vector<long long int> hole;
    hole.push_back(id);
    if (s[id] == '0') {
      while (true) {
        if (flag == 0) {
          if (beta.upper_bound(id) == beta.end()) break;
          e = *beta.upper_bound(id);
          hole.push_back(e);
          id = e;
        } else {
          if (alpha.upper_bound(id) == alpha.end()) break;
          e = *alpha.upper_bound(id);
          hole.push_back(e);
          id = e;
        }
        flag ^= 1;
      }
      if (s[hole[0]] == s[hole.back()]) hole.pop_back();
      for (auto itr : hole) {
        if (s[itr] == '0') {
          alpha.erase(itr);
          gamma.erase(itr);
        } else {
          beta.erase(itr);
          gamma.erase(itr);
        }
      }
    } else {
      flag = 1;
      while (true) {
        if (flag == 0) {
          if (beta.upper_bound(id) == beta.end()) break;
          e = *beta.upper_bound(id);
          hole.push_back(e);
          id = e;
        } else {
          if (alpha.upper_bound(id) == alpha.end()) break;
          e = *alpha.upper_bound(id);
          hole.push_back(e);
          id = e;
        }
        flag ^= 1;
      }
      if (s[hole[0]] == s[hole.back()]) hole.pop_back();
      for (auto itr : hole) {
        if (s[itr] == '0') {
          alpha.erase(itr);
          gamma.erase(itr);
        } else {
          beta.erase(itr);
          gamma.erase(itr);
        }
      }
    }
    result += 1;
  }
  return result;
}
void a2oJ() {}
void hackerRank() {}
void hackerEarth() {}
void spoj() {}
void codeForces() {}
void codeChef() {
  long long int n;
  cin >> n;
  string s, t;
  cin >> s;
  cin >> t;
  long long int zero = 0;
  long long int one = 0;
  for (long long int i = 0; i <= n - 1; i++) {
    if (s[i] == '0')
      zero++;
    else
      one++;
  }
  for (long long int i = 0; i <= n - 1; i++) {
    if (t[i] == '0')
      zero--;
    else
      one--;
  }
  long long int answer = -1;
  if (zero == 0 && one == 0) {
    answer = task(n, s, t);
  }
  cout << answer;
  cout << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long int testcase;
  testcase = 1;
  while (testcase--) {
    codeForces();
    codeChef();
    spoj();
    hackerEarth();
    hackerRank();
  }
  return 0;
}
