from itertools import combinations def is_ok(s, input): a, b, c, d, e = input chars = [s[a], s[b], s[c], s[d], s[e]] # 1文字目と3文字目が同じ if chars[0] != chars[2]: return False # 1文字目と3文字目以外が全部異なる other_chars = [chars[1], chars[3], chars[4]] if len(set(other_chars)) != 3: return False # 1文字目と3文字目以外が、1文字目と3文字目とは違う if chars[0] in other_chars: return False return True def count_cpstf(S): N = len(S) count = 0 for input in combinations(range(N), 5): if is_ok(S, input): count += 1 return count N = int(input()) S = input().strip() print(count_cpstf(S))