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