import bisect n = int(input()) s = input() idx = [] c = 0 for i in range(n): if s[i] in ["A","C","G","T"]: c += 1 idx.append(i) if c == 0: print(0) exit() c -= 1 if idx[0] >= c: print(idx[-1] + 1) else: print(idx[-1] - idx[0] + 1)