import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
  auto n = readln.chomp.to!int;
  auto s = readln.chomp;
  long cnt;

  foreach (int i; 0..n) {
    foreach (int j; i+1..n) {
      if (s[i] == s[j]) continue;
      auto ji = j - i;
      foreach (int k; j+1..n) {
        if (ji == k - j) continue;
        if (s[i] == s[k] || s[j] == s[k]) continue;
        cnt++;
      }
    }
  }
  cnt.writeln;
}
