#include <stdio.h>

int main()
{
  int N;
  scanf("%d",&N);
  char S[N+1];
  scanf("%s",&S);
  int i = 0;
  int j = 0;
  int k = 0;
  int count = 0;
  while (S[i])
  {
    j = i + 1;
    while (S[j] && j != i)
    {
      k = j + 1;
      while (S[k] && k != i && j != k)
      {
        //printf("%d%d%d",i,j,k);
        if ((j - i != k - j) && (S[i] != S[j]) && (S[i] != S[k]) && (S[j] != S[k]))
        {
          count++;
        }
        k++;
      }
      j++;
    }
    i++;
  }
  printf("%d",count);
}