import std;
enum inf(T)()if(__traits(isArithmetic,T)){return T.max/4;}
T[]readarr(T=long)(){return readln.chomp.split.to!(T[]);}
void scan(T...)(ref T args){auto input=readln.chomp.split;foreach(i,t;T)args[i]=input[i].to!t;}
struct Queue(T){T[]e;auto enq(T t){e~=t;}auto enq(T[]ts){e~=ts;}T deq(){T tp=e[0];e=e.length>1?e[1..$]:[];return tp;}}
struct Stack(T){T[]e;auto push(T t){e~=t;}auto push(T[]ts){e~=ts;}T pop(){T tp=e[$-1];e=e.length>1?e[0..$-1]:[];return tp;}}
//END OF TEMPLATE

void main(){
    readln;
    auto s=readln.chomp;
    auto n=s.length;
    long[3][] p;
    foreach(i;0..n-2){
        foreach(j;i+1..n-1){
            iota(j+1,n).filter!(k=>j-i!=k-j).each!(k=>p~=[i,j,k]);
        }
    }   
    long ans;
    foreach(c;p){
        if(s[c[0]]!=s[c[1]]&&s[c[1]]!=s[c[2]]&&s[c[2]]!=s[c[0]])
            ans++;
    }   
  