from itertools import combinations n = int(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)