n = int(input()) s = input().strip() if n < 5: print(0) else: from itertools import combinations count = 0 for indices in combinations(range(n), 5): c0 = s[indices[0]] c1 = s[indices[1]] c2 = s[indices[2]] c3 = s[indices[3]] c4 = s[indices[4]] if c0 == c2: if c1 != c0 and c3 != c0 and c4 != c0: if c1 != c3 and c1 != c4 and c3 != c4: count += 1 print(count)