/*
https://atcoder.jp/contests/abc200/tasks/abc200_e

## 題意：


## 思路：

*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 0x3fffffff;
const ll LINF = 9223372036854775807;
#define dump(x) cout << #x << " = " << (x) << endl
#define ALL(x) begin(x),end(x)
#define rep(i,s,e) for(int i=(s); i<=(e); ++i)
#define repRev(i,s,e) for(int i=(s); i>=(e); --i)
#define range(i,s,n) for(int i=(s), i_stop=(s)+(n); i<i_stop; ++i)
#define rangeRev(i,s,n) for(int i=(s), i_stop=(s)-(n); i>i_stop; --i)
template<typename T> bool chmax(T& a, const T b) {if(a<b) {a=b;return true;} return false;}
template<typename T> bool chmin(T& a, const T b) {if(a>b) {a=b;return true;} return false;}



void solve() {
    int n; cin>>n;
    string s,t; cin>>s>>t;
    vector<int> a,b;
    range(i,0,n) if(s[i]=='0') a.push_back(i);
    range(i,0,n) if(t[i]=='0') b.push_back(i);
    if(a.size() != b.size()) {printf("-1\n"); return;}

    int ans=0;
    range(i,0,a.size()) if(a[i]!=b[i]) ++ans;
    cout<<ans<<endl;
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}

    
    
#include <algorithm>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath>
#include <cstdlib> // abs(int)
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define roundup(n, d) (((n) + ((d)-1)) / (d))
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i, n) for (long long i = 0; i < (long long)n; ++i)
#define v_in(v)        \
    for (auto&& i : v) \
    cin >> i
#define vv_in(vv) rep(I, (long long)vv.size()) for (auto&& J : vv[I]) cin >> J
#define FAST_IO                  \
    ios::sync_with_stdio(false); \
    cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(), v.end()
#define printvar(x) cout << #x << ":" << x << endl

#define PI 3.14159265358979323846

using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;

int main(void) {
    FAST_IO

    ll n;
    cin >> n;
    unordered_set<string> bang;
    unordered_set<string> notbang;

    bang.reserve(n);
    notbang.reserve(n);

    rep(i, n) {
        string str;
        cin >> str;
        if (str[0] == '!') {
            string tempstr = str.substr(1);
            if (notbang.find(tempstr) != notbang.end()) {
                cout << tempstr << endl;
                return 0;
            }
            bang.emplace(tempstr);
        } else {
            if (bang.find(str) != bang.end()) {
                cout << str << endl;
                return 0;
            }
            notbang.emplace(str);
        }
    }
    cout << "satisfiable" << endl;
    return 0;
}