n = int(input()) S = list(input()) res = 0 for i in range(n - 1, -1, -1): if S[i] in ['A', 'G', 'C', 'T']: break res += 1 print(n - res)