n = int(input()) s = input() s = s[::-1] cnt = 0 for i in range(n): if s[cnt] in "AGCT": break cnt += 1 print(n - cnt)