from itertools import combinations import sys def count_cpctf_like_subseq(S: str) -> int: N = len(S) ans = 0 for i1, i2, i3, i4, i5 in combinations(range(N), 5): a, b, c, d, e = S[i1], S[i2], S[i3], S[i4], S[i5] if a == c and b != a and d != a and e != a: if b != d and b != e and d != e: ans += 1 return ans if __name__ == "__main__": input = sys.stdin.readline N = int(input().strip()) S = input().strip() print(count_cpctf_like_subseq(S))