#include <iostream>
#include <cstring>
#include <algorithm>
#include <functional>
#include <bits/stdc++.h>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <stdlib.h>
using namespace std;
 
int main () {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int c = 0;
  for (int i=1; i<n-1; i++){
    for (int j = i+1; j<n; j++){
      for (int k = j+1; k<=n; k++){
        if (s[i]!=s[j] && s[i]!=s[k] && s[j]!=s[k] && (j-i)!=(k-j)){
          c ++;
        }
      }
    }
  }
  cout << c;
  return 0;
}