#include<bits/stdc++.h>
using namespace std;
int n,a,b;
int main()
{
	cin>>n>>a>>b;
	cout<<n-a+b;
}
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;

int sled0[500005];
int sled1[500005];
int mvs[500005];

int main(){
    ios_base::sync_with_stdio(false), cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    string aa = s, bb = t;
    sort(aa.begin(), aa.end());
    sort(bb.begin(), bb.end());
    if(aa != bb){
        cout << -1;
        return 0;
    }
    vector <int> p;
    vector <int> d;
    for(int i=0; i<n; i++){
        if(s[i] == '0') p.push_back(i);
        if(t[i] == '0') d.push_back(i);
    }
    int res = 0;
    for(int i=0; i<p.size(); i++){
        if(p[i] != d[i]) res++;
    }
    cout << res;
    return 0;
}
