#include <iostream>
#include <string>
using namespace std;

int main(){
    int n;
    string str;
    cin >> n >> str;
    int count = 0;
    
    for(int a=1; a<=n-2; a++){
      for(int b=a+1; b<=n-1; b++){
        for(int c=b+1; c<=n; c++){
          if(str.at(a-1) != str.at(b-1) && str.at(b-1) != str.at(c-1) && str.at(a-1) != str.at(c-1)){
            if(a - (2*b) + c != 0){
              count++;
            }
          }
        }
      }
    }
    cout << count << endl;
    return 0;
}