import std;

void main()
{
  const N = readln().chomp().to!ulong();
  const S = readln().chomp();
  
  size_t count = 0;
  
  foreach (index; 0 .. N)
  {
    foreach (i; 0 .. N)
    foreach (j; 0 .. N)
    foreach (k; 0 .. N)
    {
      if (S[i] == S[j]) continue;
      if (S[i] == S[k]) continue;
      if (S[j] == S[k]) continue;
      if (j - i == k - j) continue;
      count++;
    }
  }
  
  writeln(count);
}