#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

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);
    }
};

const int N = (int)2e5+5;
const int M = (int)3e3+5;
const int Q = 301;
const int logN = 19;

void solve() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    REP(i,0,n-1) {
      unordered_map<char,int> freq;
      REP(j,i,n-1) {
        freq[s[j]]++;
        if(freq['A'] == freq['T'] && freq['C'] == freq['G']) {
          ans++;
        }
      }
    }
    cout << ans;
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    // cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}

#include <bits/stdc++.h>
using namespace std;
#define LL long long
//#define MOD 1000000007
#define MOD 998244353
#define INF 1000000000000000000
#define VE vector
#define VL vector<LL>
#define VVL VE<VL>
#define VVVL VE<VVL>
#define LD long double
#define PB push_back
#define POB pop_back
#define FOR(i,a,k) for(LL i=a;i<k;i++)
#define rep(i,k) FOR(i,0,k)
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define coutl cout<<fixed<<setprecision(15)//

#define MI modint<MOD>
template<int mod>struct modint{
	int x;
	modint():x(0){}
	modint(LL n):x(n>=0?n%mod:(mod-(-n)%mod)%mod){}
	modint &operator+=(const modint &n){if((x+=n.x)>=mod)x-=mod;return *this;}
	modint &operator-=(const modint &n){if((x+=mod-n.x)>=mod)x-=mod;return *this;}
	modint &operator++(){*this+=1;return *this;}
  modint &operator--(){*this-=1;return *this;}
	modint &operator*=(const modint &n){x=(int)((LL)x*n.x%mod);return *this;}
	modint &operator/=(const modint &n){*this*=n.inv();return *this;}
	modint operator-()const{return modint(-x);}
	modint operator+(const modint &n)const{return modint(*this)+=n;}
	modint operator-(const modint &n)const{return modint(*this)-=n;}
	modint operator++(int){modint ret(*this);*this+=1;return ret;}
  modint operator--(int){modint ret(*this);*this-=1;return ret;}
	modint operator*(const modint &n)const{return modint(*this)*=n;}
	modint operator/(const modint &n)const{return modint(*this)/=n;}
	bool operator<(const modint &n)const{return x<n.x;}
	bool operator>(const modint &n)const{return x>n.x;}
	bool operator<=(const modint &n)const{return x<=n.x;}
	bool operator>=(const modint &n)const{return x>=n.x;}
	bool operator!=(const modint &n)const{return x!=n.x;}
	bool operator==(const modint &n)const{return x==n.x;}
	friend istream &operator>>(istream &is,modint &n){LL l;is>>l;n=modint<mod>(l);return is;}
	friend ostream &operator<<(ostream &os,const modint &n){return os<<n.x;}
	int getmod(){return mod;}
	modint inv()const{int a=x,b=mod,c=1,d=0,n;while(b){n=a/b;swap(a-=n*b,b);swap(c-=n*d,d);}return modint(c);}
	modint pow(LL n)const{modint ret(1),m(x);while(n){if(n&1)ret*=m;m*=m;n>>=1;}return ret;}
};

VL yakusuu(LL N){
	LL M=0;
	VL ret;
	for(LL i=0; i<N; i++){
		M++;
		if(M>N/M){
			for(LL i=0; i<N; i++){
				M--;
				if(M==0){
					return ret;
				}
				if(M*M==N){
					continue;
				}
				if(N%M==0){
					ret.PB(N/M);
				}
			}
		}
	  if(N%M==0){
		  ret.PB(M);
		}
	}
	return ret;
}

LL nanjo(LL a,LL n){//aのn乗  N=nanjo(a,n)A
	LL ret=1;
	for(LL i=0;i<n;i++){
		ret*=a;
	}
	return ret;
}

void YesNo(bool f){
	if(f)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

LL kakuketa(LL n){//各桁の和を求める
	LL a=0;
	while(n>0){
		a=a+n%10;
		n=n/10;
	}
	return a;
}

int main(){
	LL M,ans=0,N;
	cin>>N;
	M=N;
	rep(i,20){
		if(M>=10){
			M=M/10;
		}
		if(M<10){
			M=i+2;
			break;
		}
	}
	if(M>=0){
		ans=0;
	}
  if(M>=4){
		ans+=N-999;
	}
	if(M>=7){
		ans+=N-999999;
	}
	if(M>=10){
		ans+=N-999999999;
	}
	if(M>=13){
		ans+=N-999999999999;
	}
	if(M>=16){
		ans+=N-999999999999999;
	}
	cout<<ans<<endl;
	/*LL N,ans;
	cin>>N;
	rep(i,N){
		if(N%10==)
	}
	/*LL K,ans=0;
	cin>>K;
	ans=K-2;//全部同じ数だった場合
	if(K>=4){
		ans+=(1+(K-2)/2)*K/2*3;//２つ同じ数があった場合
	}
	if(K>=6){
		ans+=(1+(K/2+1)*K/6)**6;
	}
	cout<<ans<<endl;
	LL N,M,T,ans=0;
	cin>>N>>M>>T;
	ans=N;
	VL A(M),B(M);
	rep(i,M){
		cin>>A[i]>>B[i];
	}
	rep(i,M){
		ans=ans-A[i]+A[i-1];
		if(ans<=0){
			cout<<"No"<<endl;
			break;
		}
		ans=ans+(B[i]-A[i]);
		if(ans>=M){
			ans=N;
		}
	}
	cout<<"Yes"<<endl;*/
}
