#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  ll res = 0;
  for (int i = 1; i <= n - 2; ++i) {
    for (int j = i + 1; j <= n - 1; ++j) {
      int ij = j - i;
      if (s[i - 1] == s[j - 1]) {
        continue;
      }
      for (int k = j + 1; k <= n; ++k) {
        int jk = k - j;
        if (ij == jk) {
          continue;
        }
        if (s[i - 1] == s[k - 1]) {
          continue;
        }
        if (s[j - 1] == s[k - 1]) {
          continue;
        }
        res++;
      }
    }
  }
  cout << res << endl;

  return 0;
}
