from itertools import combinations input() S = input() ans = 0 for C in combinations(S, 5): if C[0]==C[2] and len(set(C))==4: ans += 1 print(ans)