#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<iomanip>
#include<regex>
using namespace std;
#define int long long
const int mod=1e9+7;
bool pri[1000001],squf[1000001],even[1000001];
signed main(){
	int l,r;
	cin>>l>>r;
	for(int i=2;i<=r;i++)
		pri[i]=squf[i]=even[i]=1;
	for(int i=2;i<=r;i++){
		if(!pri[i])
			continue;
		for(int j=i;j<=r;j+=i){
			if(j!=i)
				pri[j]=0;
			even[j]=!even[j];
		}
		for(int j=i*i;j<=r;j+=i*i)
			squf[j]=0;
	}
	int ans1=0,ans2=0;
	for(int g=2;g<=r;g++){
		if(!squf[g])
			continue;
		int a=r/g-(l-1)/g;
		a=a*(a-1)/2;
		if(even[g])
			ans1-=a;
		else
			ans1+=a;
	}
	for(int g=max(2ll,l);g<=r;g++)
		ans2+=r/g-1;
	cout<<(ans1-ans2)*2<<endl;
}



#include <bits/stdc++.h>

#define loop(s, e, i) for (int i = s; i < e; ++i)
#define print(s) cout << s << endl;
#define DIV 1000000007
#define ll long long
using namespace std;

/*
浮動小数点の入力
cout << fixed << setprecision(9) << endl;
*/

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  string S;
  cin >> N >> S;

  int A=0, T=0, C=0, G = 0;
  vector<int> AV(N+1), TV(N+1), CV(N+1), GV(N+1);
  loop(0, S.size(), i) {
    switch(S[i]) {
      case 'A':
        A += 1;
        break;
      case 'T':
        T += 1;
        break;
      case 'C':
        C += 1;
        break;
      case 'G':
        G += 1;
        break;
    }
    AV[i+1] = A;
    TV[i+1] = T;
    CV[i+1] = C;
    GV[i+1] = G;
  }

  int count = 0;
  loop(0, S.size()+1, i) {
    loop(i+2, S.size()+1, j) {
      int ad = AV[j] - AV[i];
      int td = TV[j] - TV[i];
      int cd = CV[j] - CV[i];
      int gd = GV[j] - GV[i];
      if (ad == td && cd == gd){
        count++;
      } 
    }
  }
  print(count);
}