from string import ascii_uppercase from itertools import permutations N = int(input()) S = input() ans = 0 for p in permutations(ascii_uppercase, 4): dp = [0] * 6 dp[0] = 1 for c in S: if c == p[3]: dp[5] += dp[4] if c == p[2]: dp[4] += dp[3] if c == p[0]: dp[3] += dp[2] if c == p[1]: dp[2] += dp[1] if c == p[0]: dp[1] += dp[0] ans += dp[5] print(ans)