N = int(input()) S = list(input()) cnt = 0 for i in range(N): if S[i] in "AGCT": cnt += 1 if cnt == 0: print(0) exit() ans = 0 while True: ans += 1 p = S.pop(cnt - 1) if p in "AGCT": cnt -= 1 if cnt == 0: break print(ans)