input() S = input().strip() N = len(S) count = 0 for i in range(N): for j in range(i+1, N): for k in range(j+1, N): for l in range(k+1, N): for m in range(l+1, N): a, b, c, d, e = S[i], S[j], S[k], S[l], S[m] if a != c: continue # s1 == s3 ではないのでNG # s1==s3 なので s1 と s3 は a としてOK # 残りの文字 b, d, e と a がすべて異なる必要がある if len(set([a, b, d, e])) != 4: continue # さらに b, d, e が互いに異なることを確認(たとえば a と違うが b==d とかはNG) if len(set([b, d, e])) != 3: continue count += 1 print(count)