#include<iostream>
#include<string.h>
#include<bits/stdc++.h>
#include<cctype>
#include<cstring>
using namespace std;
int main()
{
    string s;
    char c;
    int flag1=1,flag2=1;
    cin>>s;
    int l = s.length();
    for (int i = 0; i < l; i+=2)
    {
        if(i==l)
        break;
        c=s.at(i);
        if(isupper(c) != 0)
        flag1 = 0;
    }
    for (int i = 1; i < l; i+=2)
    {
        if(i==l)
        break;
        c=s.at(i);
        if(isupper(c) == 0)
        flag1 = 0;
    }
    if(flag1==1 && flag2==1)
    cout<<"Yes"<<endl;
    else
    {
        cout<<"No"<<endl;
    }
    return 0;    
}
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <random>
#include <chrono>
#include <numeric>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 567890;
char S[MAXN], T[MAXN];

int main() {
    int N;
    scanf("%d", &N);
    scanf("%s", S);
    scanf("%s", T);
    vector<int> idx, idx2;
    for (int i = 0; i < N; i++)
        if (S[i] == '0')
            idx.push_back(i);

    for (int i = 0; i < N; i++)
        if (T[i] == '0')
            idx2.push_back(i);

    if (idx.size() != idx2.size()) return !printf("-1\n");

    int ans = 0;

    for (int i = 0; i < (int)idx.size(); i++) {
        int want = idx2[i];
        int cur = idx[i];
        if (cur == want) continue;
        ans++;
    }
    printf("%d\n", ans);
    return 0;
}
/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
    * DON'T GET STUCK ON ONE APPROACH
by Benq;
*/
