#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, i, j, k, result;
  string S;
  cin >> N >> S;
  if (N == 1 || N == 2) {
    cout << '0' << endl;
  }
  result = 0;
  for (i = 0; i < N - 2; i++) {
    for (j = i + 1; j < N - 1; j++) {
      for (k = j + 1; k < N; k++) {
        if (j - i != k - j) {
          if (S[i] != S[j] && S[j] != S[k] && S[k] != S[i]) {
            result++;
          }
        }
      }
    }
  }
  cout << result << endl;
}