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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  long long ans = 0;
  for (int i = 1; i <= N; i++) {
    for (int j = i; j <= N; j++) {
      for (int k = j; k <= N; k++) {
        if (S[i-1] != S[j-1] && S[j-1] != S[k-1] && S[k-1] != S[i-1] && j-i != k-j) {
          ans++;
        }
      }
    }
  }
  cout << ans;
}