from itertools import combinations N = int(input()) S = input() print(sum(1 for a in combinations(S, 5) if a[0] == a[2] and len(set(a)) == 4))