#include <bits/stdc++.h>
using namespace std;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ll long long 
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define clr(x) memset(x,0,sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it,a) for(auto it=a.begin();it!=a.end();it++)
#define PI 3.1415926535897932384626
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
int mpow(int base,int exp);
void ipgraph(int n,int m);
void dfs(int u,int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];


void solve(){
  int n,w;
  cin >> n >> w;
  cout << (n/w);
}

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

  int t = 1;
  //cin >> t;
  while(t--){
    solve();
  }

  return 0;
}

int mpow(int base,int exp){
  base %= mod;
  int result = 1;
  while(exp > 0){
    if(exp & 1)
      result = ((ll)result * base) % mod;
    
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }

  return result;
}

void ipgraph(int n,int m){
  int i, u, v;

  while(m--){
    cin >> u >> v;
    u-- , v--;
    g[u].pb(v);
    g[v].pb(u);
  }

}



#include <bits/stdc++.h>

using namespace std;

int main() {
	int n;
	string s;
	cin >> n >> s;
	
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		int c1 = 0, c2 = 0;
		for (int j = i; j < n; ++j) {
			if (s[j] == 'A') c1++;
			else if (s[j] == 'T') c1--;
			else if (s[j] == 'C') c2++;
			else c2--;
			if (c1 == 0 && c2 == 0) ans++;
		}
	}
	
	cout << ans << '\n';
	
	return 0;
}