from collections import defaultdict


def main():
    N = int(input())
    S = input()

    c = 0

    for i in range(N):
        for j in range(i, N):
            for k in range(j, N):
                if j - i != k - j and S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                    c += 1

    print(c)


if __name__ == '__main__':
    main()
