#include<bits/stdc++.h>
using namespace std;
bool flag;
string x[10000010];
int main(void){
	long long n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>x[i];
		reverse(x[i].begin(),x[i].end());
	}
	sort(x+1,x+n+1);
	for(int i=1;i<n;i++){
		if(x[i]+'!'==x[i+1]){
			reverse(x[i].begin(),x[i].end());
			cout<<x[i]<<endl;
			flag=1;
			break;
		}	
	}
	if(flag!=1){
		cout<<"satisfiable";
	}
}
#include <bits/stdc++.h>
using namespace std;


#define ll long long int
#define ld long double
#define mod 998244353
#define big 1e18 + 1000000
#define small -big
#define pb push_back
#define endl "\n"


template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}




void solve() {
        
         ll N;
         cin >> N;
         
         char A[N + 1];
        
         for(ll i = 1; i <= N; i++) {
                cin >> A[i];
                
         }
         
          ll ans[N + 1][26];
         memset(ans, 0, sizeof(ans));
         
         
         for(ll i = 1; i <= N; i++) {
                
                for(ll j = 0; j < 26; j++) {
                        ans[i][j] += ans[i - 1][j];
                }
                ans[i][A[i] - 65]++;
                
         }
         
         ll d = 0;
         
         for(ll i = 1; i <= N; i++) {
                for(ll j = i; j <= N; j++) {
                        ll a = ans[j]['A' - 65] - ans[j - i]['A' - 65];
                        ll c = ans[j]['C' - 65] - ans[j - i]['C' - 65];
                        ll g = ans[j]['G' - 65] - ans[j - i]['G' - 65]; 
                        ll t = ans[j]['T' - 65] - ans[j - i]['T' - 65];
                        
                        if(a == t && g == c) {
                                d++;
                        }
                }
         }
         
         
         cout << d << endl;
          
          
          
          
         
}




int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    

    int t=1;
    //cin >> t;

    for(int i = 1; i <= t; i++) {  
   
         solve();
    }


    return 0;
        
}
