#include<bits/stdc++.h>
using namespace std;
const int maxn=5e5+100;
int read()
{
	int ans=0;bool f=0;char ch=getchar();
	while(ch<'0' or ch>'9'){if(ch=='-')f=1;ch=getchar();}
	while(ch>='0' and ch<='9'){ans=(ans<<1)+(ans<<3)+(ch^48);ch=getchar();}
	return f?~ans+1:ans;
}
int n,ans,nx[maxn],per[maxn];
char s1[maxn],s2[maxn];
vector<int>g1,g2;
int abx(int x)
{
	return x>0?x:-x;
}
int main()
{
	n=read();
	scanf("%s%s",s1+1,s2+1);
	int now=1;
	for(int i=1;i<=n;++i)
	{
		if(s1[i]=='0')
		g1.push_back(i);
		if(s2[i]=='0')
		g2.push_back(i);
	}
	nx[now]=n+1;
	if(g1.size()!=g2.size())
	{
		puts("-1");
		return 0;
	}
	for(int i=0;i<g1.size();++i)
	{
		ans+=abx(g1[i]-g2[i])!=0;
	}
	cout<<ans;
	return 0;
}
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline")
#pragma GCC optimize(3 , "Ofast" , "inline")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <unordered_map>
#include <vector>
#include <map>
#include <list>
#include <queue>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <stack>
#include <set>
#include <bitset>
#include <deque>
using namespace std ;
#define ios ios::sync_with_stdio(false) , cin.tie(0)
#define x first
#define y second
#define pb push_back
#define ls rt << 1
#define rs rt << 1 | 1
typedef long long ll ;
const double esp = 1e-6 , pi = acos(-1) ;
typedef pair<int , int> PII ;
const int N = 1e6 + 10 , INF = 0x3f3f3f3f , mod = 1e9 + 7;
int n ;
string a , b ;
vector<int> va , vb ;
int work()
{
  cin >> n >> a >> b ;
  for(int i = 0 ;i < a.size() ;i ++ ) 
  	 if(a[i] == '0') va.pb(i) ;
  for(int i = 0 ;i < b.size() ;i ++ ) 
  	 if(b[i] == '0') vb.pb(i) ;
  if(va.size() != vb.size()) return puts("-1") , 0 ;
  int ans = 0 ;
  for(int i = 0 ;i < va.size() ;i ++ ) 
  	if(va[i] != vb[i]) ans ++ ;
  cout << ans << "\n" ;
  return 0 ;
}
int main()
{
  //   freopen("C://Users//spnooyseed//Desktop//in.txt" , "r" , stdin) ;
  //   freopen("C://Users//spnooyseed//Desktop//out.txt" , "w" , stdout) ;

  work() ;
  return 0 ;
}
/*

*/
	