/*
Author- Aasav Badera
Time- Sat Oct  3 17:21:39 2020
*/
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#pragma GCC optimize("-O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma") 
using namespace std;
using namespace __gnu_pbds;
#ifdef LOCAL  
#include <sys/resource.h>
#define meminc             rlimit rlim;if (getrlimit(RLIMIT_STACK, &rlim)) return 1;rlim.rlim_cur = 268435456;if (setrlimit(RLIMIT_STACK, &rlim)) return 2;
#else
#define meminc      
#endif
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 int
#define vi                 vector<int >
#define ordered_set        tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define rep(i, a, b)       for(int  i=a;i<b;i++)
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (int )x.size()
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define endl               '\n' 
// const int hell = (int)998244353;
const int hell = (int)1e9 + 7;
const long long int inf = 3223372036854775807;
const double PI = 3.14159265;
const int N = (int) 1e6 + 5;
int n, m, k, a[N];


int32_t main()
{
    meminc;
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cerr.precision(10);
    cout.precision(25);
    cout << fixed;
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    int tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
        cin >> n;
        string s;
        cin >> s;
        long long int ans = 0;
        int cntr[n][4] = {0};
        map<char, int> m1;
        m1['A'] = 0;
        m1['T'] = 1;
        m1['G'] = 2;
        m1['C'] = 3;
        rep(i, 0, n)
        {
        	rep(j, 0, 4)
        	{
        		if(j == m1[s[i]])cntr[i][j] = 1;
        		else cntr[i][j] = 0;
        	}
        	if(i)
        	{
        		rep(j, 0 ,4)
        		{
        			cntr[i][j] += cntr[i - 1][j];
        		}
        	}
        }
        rep(i, 0, n)
        {
        	rep(j, i, n)
        	{	
        		int itm[4];
        		rep(l, 0 ,4)
        		{
        			itm[l] = cntr[j][l];
        			if(i)
        			{
        				itm[l] -= cntr[i - 1][l];
        			}
        			dbg(i, j, l, itm[l]);
        		}
        		ans += ((itm[0] == itm[1]) and (itm[3] == itm[2]));
        	}
        }
        cout << ans << endl;
    }
    #ifdef LOCAL
        // cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
    return 0;
}
#include<bits/stdc++.h>
#define fl(i,a,n)      for(int i=a;i<=n;i++)
#define pb             push_back
#define int            long long int
#define ump            unordered_map
#define pii            pair<int,int>
#define ff             first
#define ss             second
#define PI             3.1415926535898
#define inf            1e18
#define all(x)         x.begin(),x.end()
#define vi             vector<int>
#define endl           "\n"
#define print(a)       for(auto x:a){cout<<x<<" ";}cout<<endl;
#define mod            1000000007
using namespace std;
template <typename Arg, typename... Args>
void db(Arg&& arg, Args&&... args) {
    cout << std::forward<Arg>(arg);
    using expander = int[];
    (void)expander{0, (void(cout << ',' << std::forward<Args>(args)), 0)...}; cout << endl;
}
bool func(vector<vector<int>>&dp, int i, int rem, string &s, string &x) {
    if (i == s.size()) {
        return rem == 0;
    }
    if (dp[i][rem] != -1) {
        return dp[i][rem];
    }
    bool f;
    if (x[i] == 'A') {
        f = (func(dp, i + 1, (rem * 10) % 7, s, x) and func(dp, i + 1, (rem * 10 + (s[i] - '0')) % 7, s, x));
    }
    else {
        f = (func(dp, i + 1, (rem * 10) % 7, s, x) or func(dp, i + 1, (rem * 10 + (s[i] - '0')) % 7, s, x));
    }
    return dp[i][rem] = f;
}
inline void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    string x;
    cin >> x;
    vector<vector<int>>dp(n, vector<int>(7, -1));
    if (func(dp, 0, 0, s, x)) {
        cout << "Takahashi";
    }
    else
    {
        cout << "Aoki";
    }
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    // cin >> t;
    fl(i, 1, t)
    {
        solve();
    }

    return 0;
}