#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  int n;
  cin >> n;
  string s;
  cin >> s;
  
  vector<int> sumA(n+1,0);
  vector<int> sumG(n+1,0);
  vector<int> sumC(n+1,0);
  vector<int> sumT(n+1,0);
  
  rep1(i,n){
    sumA[i] = sumA[i-1] + (s[i-1] == 'A');
    sumG[i] = sumG[i-1] + (s[i-1] == 'G');
    sumC[i] = sumC[i-1] + (s[i-1] == 'C');
    sumT[i] = sumT[i-1] + (s[i-1] == 'T');
  }
  int ans = 0;
  rep(i,n){
    for(int j=i+1;j<n+1;j++){
      int nowA = sumA[j]-sumA[i];
      int nowG = sumG[j]-sumG[i];
      int nowC = sumC[j]-sumC[i];
      int nowT = sumT[j]-sumT[i];
      if(nowA == nowT && nowC == nowG) ans ++;
    }
  }
  cout << ans << endl;
}

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <utility>
#include <unordered_set>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define reps(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
const int MOD = 1000000007;



int main(){
    ll n;
    cin>>n;
    ll m;
    cin>>m;
    vector<string> s(n);
    for (ll i = 0; i < n; i++) {
		cin >> s[i];
	}
    vector<ll> cnt(n,0);
    rep(i,n){
        rep(j,m){
            if(s[i][j]=='1'){
                cnt[i]++;
            }
        }
    }

    ll odd=0,even=0;
    for( auto x : cnt){
        if(x%2==0){
            even++;
        }else{
            odd++;
        }
    }
    
    cout<<odd*even<<endl;
    
}