#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define pb push_back
#define mod 1000000007
#define mp make_pair

ll fact[200005];

ll powermod(ll x,ll y){
  if(y==0) return 1;
  ll temp = powermod( x,y/2 )%mod;
  if( y%2 ){
    return (((temp*temp)%mod)*x%mod);
  }
  return (temp*temp)%mod;
}

ll power(ll x,ll y){
  if(y==0) return 1;
  ll temp = power( x,y/2 );
  if( y%2 ){
    return (((temp*temp))*x);
  }
  return (temp*temp);
}

int gcd (int a, int b) {
    return b ? gcd (b, a % b) : a;
}

ll inv(ll a, ll p){
	return powermod(a,mod-2);
}
 
ll nCr(ll n, ll r, ll p){
	if(r > n) return 0;
	ll t1 = fact[n];
	ll t2 = inv(fact[r],p);
	ll t3 = inv(fact[n-r],p);
 
	return (((t1*t2)%p)*t3)%p;
}


void solve(){
  ll n,i,j,a,b,c;
  cin>>n;
  string s,t;
  cin>>s>>t;
  vector<int>s0,t0;
  for(i=0;i<n;i++){
    if(s[i]=='0')s0.pb(i);
    if(t[i]=='0')t0.pb(i);
  }
  if(t0.size()!=s0.size())cout<<"-1";
  else{
    ll ans=0;
    for(i=0;i<t0.size();i++){
      if(t0[i]!=s0[i])ans++;
    }
    cout<<ans;
  }
  return;
}

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  ll t=1;
  //cin>>t;
  //srand(time(0));
  // fact[0]=1;
  // for(int i=1;i<200001;i++){
  //   fact[i]=i*fact[i-1];
  //   fact[i]%=mod;
  // }
  while (t--){
    solve();
  }
  return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for( ll i = a; i < b ; i++ )
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ones(numeros) (ll) __builtin_popcountll(numeros)
#define fs first
#define sc second
#define pb push_back
#define po pop_back
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ller ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define watch(x) cout << (#x) << " es " << (x) <<"\n"
#define test ll deftestcases;cin>>deftestcases;while(deftestcases--)
#define PI acos(-1)
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> ii;
typedef pair<ll,ii> iii;
typedef vector<ll>  vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
const ll inf = 2e18;
const ll mod = 998244353;   
const ll MAX = 1e6+12;

int main(){
    fastio;
    ll a,b,c;cin>>a>>b>>c;
    cout<<21-(a+b+c)<<"\n";
    return 0; 
}