""" あらかじめ反転 1色にできるか? """ from sys import stdin N = n = int(stdin.readline()) s = list(stdin.readline()[:-1]) oa = ord("A") agct = [ord("A")-oa , ord("G")-oa, ord("C")-oa, ord("T")-oa] for i in range(N): s[i] = ord(s[i])-oa ans = 0 for loop in range(n): c1 = 0 for i in range(len(s)): if s[i] in agct: c1 += 1 if c1 == 0: break ans += 1 t = [] c2 = 0 CC = s[c1-1] for i in range(len(s)): if i != c1-1: t.append(s[i]) if s[i] == CC: c2 += 1 for i in range(len(t)): t[i] += c2 t[i] %= 26 s = t print (ans)