#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  string s;
  cin >> n >>s;
  int ans=0;
  rep(i,n) {
    rep(j,n) {
      rep(k,n) {
        if((j-i)==(k-j)) continue;
        else if(s[i]==s[k]||s[i]==s[j]||s[k]==s[j]) continue;
        else ans++
      }
    }
  }
  cout << ans << endl;
}