#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;
 
int main() {

int n;cin>>n;
 struct pair{char x; int y; }
  Data d[n]; 
  
  for( int k = 0; i < n; k++ ){
      d[k].y = i; // 1,2,3,...となるようにする 
      cin>>d[k].x;
}
  
  sort(all(d.x));
  int r=0,g=0,b=0;
  
  rep(j,n-1){
    if(a.at(i)==a.at(i+1)){b++;}
    else break;
  }
  {if(a.at(i)==a.at(i+1)){g++;}
    else break;}
  
  r=n-b-g;
  sort(all(d.y));
  int minus;
  
  rep(m,n){
  	REP(h,1,n){if(h<=m||d[m].x==d[h].x){h++;}  
      else if{REP(f,2,n){if(f<=h||d[h].x!=d[f].x){f++;}
        else if(h*2==m+f){minus++;}}}}}
  
  
  ll com=r*g*b;
  cout<<com-minus<<endl;
  
}