import math n = int(input()) c = input() l = [] r = [] for i in range(n): if r.count(c[i]) == 0: l.append(l.count(c[i])) r.apprnd(c[i]) if len(l) < 5 or math.prod(l) <= 1: print(0) else: a = len(l) - l.count(1) b = len(l) ans = a * b * (b-1) /2 print(int(ans))