#include<stdio.h>
#include<stdlib.h>

int main(void){
    int n;
    char s[4010];
    int sum=0;
    scanf("%d",&n);
    scanf("%s",s);

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                //print("i,j,k:{},{},{}".format(i,j,k))
                if(!(i<j&&j<k)){
                    continue;
                }
                if(s[i]=="R"&&s[j]=="G"&&s[k]=="B"&&(j-i!=k-j)){
                    sum+=1;
                    //#print("i,j,k:{},{},{}".format(i,j,k))
                }else if (s[i]=="R"&&s[j]=="G"&&s[k]=="B"&&(j-i!=k-j)){
                    sum+=1;
                    //#print("i,j,k:{},{},{}".format(i,j,k))
                }else if (s[i]=="R"&&s[j]=="G"&&s[k]=="B"&&(j-i!=k-j)){
                    sum+=1;
                    //#print("i,j,k:{},{},{}".format(i,j,k))
                }else if (s[i]=="R"&&s[j]=="G"&&s[k]=="B"&&(j-i!=k-j)){
                    sum+=1;
                    //#print("i,j,k:{},{},{}".format(i,j,k))
                }else if (s[i]=="R"&&s[j]=="G"&&s[k]=="B"&&(j-i!=k-j)){
                    sum+=1;
                    //#print("i,j,k:{},{},{}".format(i,j,k))
                }else if (s[i]=="R"&&s[j]=="G"&&s[k]=="B"&&(j-i!=k-j)){
                    sum+=1;
                    //#print("i,j,k:{},{},{}".format(i,j,k))
                }
            }
        }
    }
    print(sum);
    return 0;
}