n = int(input()) S = input() se = set() for i in range(1, n): lst = [] if S[i - 1] == "A": lst.append(i - 1) if S[i] == "A": lst.append(i) tot = 0 for l in lst: tot *= n + 1 tot += l + 1 se.add(tot) print(len(se))