#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vcc = vector<vc>;
using Pii = pair<int,int>;
using ld = long double;

#define rep(i,n) for(int i = 0; i<(int)n; i++)
#define per(i,n) for(int i = n-1; i>=0; i--)
#define mysort(V) sort(V.begin(),V.end())
#define myreverse(V) reverse(V.begin(),V.end())
#define myunique(V) V.erase( unique(V.begin(), V.end()), V.end() );
#define print(s) cout << s << endl;

const ld PI = 3.14159265358979;
const long long INF = 12345678909876;

long long powll(long long x, long long n){
    if(n == 0) return 1;
    else       return powll(x,n-1)*x;
}

long long gcd(long long a, long long b){
    if(a%b==0) return b;
    else return gcd(b,a%b);
}


int main(){
    int N;
    string s,t;
    cin >> N >> s >> t;
    vector<int> A(0),B(0);
    for(int i = 0; i<s.size(); i++){
        if(s[i]=='0'){
            A.push_back(i);
        }
    }
    for(int j = 0; j<s.size(); j++){
        if(t[j]=='0'){
            B.push_back(j);
        }
    }
    int ans = 0;
    if(A.size()!=B.size()){
        ans = -1;
    }
    else{
        for(int i = 0; i<A.size(); i++){
            if(A[i]!=B[i]){
                ans++;
            }
        }
    }
    cout << ans << endl;

}


#include <bits/stdc++.h>
// #include <atcoder/all>
using namespace std;
// using namespace atcoder;
 
#define rp(i, k, n) for (int i = k; i < n; i++)
using ll = long long;
using ld = long double;
 
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
// const ll MOD = 998244353;
const double PI=3.14159265358979323846;

int mygcd(int n, int m) {  // 最大公約数を求めるプログラム
    // nとmの最大公約数を返す関数
    if(m > n) {
        int c = n;
        n = m; 
        m = c;
    }
    if(n%m == 0) return m;
    else return mygcd(m, n%m);
}

int main() {
    int n; cin >> n;
    string s, x; cin >> s >> x;
    vector<vector<int>> dp(200010, vector<int>(7));
    // dp[i][j] ... i番目の手番でT%7=jだった場合の勝敗
    // 0ならAoki, 1ならTakahashi
    dp[n][0] = 1;
    for(int i = n-1; i >= 0; i--) {
        int a = s[i] - '0';
        rp(j, 0, 7) {
            int b = (j*10 + a) % 7;
            int c = (j*10) % 7;
            if(x[i] == 'A') {
                // aと0どちらを加えても7の倍数になる場合、1
                if(dp[i+1][b] == 1 and dp[i+1][c] == 1) {
                    dp[i][j] = 1;
                }
            } else {
                if(dp[i+1][b] == 1 or dp[i+1][c] == 1) {
                    dp[i][j] = 1;
                }
            }
        }
    }
    if(dp[0][0] == 1) cout << "Takahashi" << endl;
    else cout << "Aoki" << endl;
    return 0;
}
