n = int(input()) s = input() A = [i for i, x in enumerate(s) if x == "A"] G = [i for i, x in enumerate(s) if x == "G"] C = [i for i, x in enumerate(s) if x == "C"] T = [i for i, x in enumerate(s) if x == "T"] AGCT = A + G + C + T AGCT.sort() if len(AGCT) == 0: print(0) else: print(AGCT[-1] + 1)