def solve(n, s): count = 0 # Try all possible combinations of 5 positions 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): # Check if characters at positions i and k are equal (1st and 3rd positions) if s[i] == s[k]: # Check if all other characters are different if s[j] != s[i] and s[l] != s[i] and s[m] != s[i] and s[j] != s[l] and s[j] != s[m] and s[l] != s[m]: count += 1 return count # Read input n = int(input()) s = input() print(solve(n, s))