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>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
const long long int MOD = 1e9 + 7;
const long long int MOD1 = 998244353;
const long long int N = 2e5 + 5;
const long long int INF = 1000111000111000111LL;
const long double EPS = 1e-12;
const long double PI = 3.141592653589793116;
string s, t;
vector<long long int> v;
int32_t main() {
  std::ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  cin >> s >> t;
  long long int c1 = 0, c2 = 0;
  for (long long int i = 0; i < n; i++) {
    if (s[i] == '1' && t[i] == '0') {
      c1++;
      v.push_back(1);
    }
    if (s[i] == '0' && t[i] == '1') {
      c2++;
      v.push_back(2);
    }
  }
  if (s == t) {
    return cout << 0, 0;
  }
  if (c1 != c2) return cout << -1, 0;
  if (c1 == 0) {
    return cout << 0, 0;
  }
  long long int ans = 0;
  set<long long int> s1, s2;
  for (long long int i = (0); i < ((long long int)((v).size())); i++) {
    if (v[i] == 1)
      s1.insert(i);
    else
      s2.insert(i);
  }
  long long int Tc = c1;
  while (Tc--) {
    long long int init = *s1.begin();
    vector<long long int> v1, v2;
    for (auto it = s1.begin(); it != s1.end();) {
      auto nt = s2.upper_bound(*it);
      if (nt == s2.end()) {
        if (*s2.begin() > *s1.begin()) break;
        v2.push_back(*s2.begin());
        v1.push_back(*it);
        break;
      }
      v2.push_back(*nt);
      v1.push_back(*it);
      it = s1.upper_bound(*nt);
    }
    if ((long long int)((v1).size())) {
      ans++;
    } else {
      break;
    }
    for (auto it : v1) s1.erase(it);
    for (auto it : v2) s2.erase(it);
  }
  cout << ans;
  return 0;
}
