N = int(input()) S = input() ans=0 #c=S.count("A")+S.count("G")+S.count("C")+S.count("T") pos=[] c=0 for i in range(N): if S[i]=="A" or S[i]=="G" or S[i]=="C" or S[i]=="T": pos.append(i) c+=1 if c>0: ans=0 kesu=c-1 moto=c-1 next=c-1 for i in range(N): # print(next) ans+=1 if next in pos: moto-=1 next=moto if moto<0: break else: kesu+=1 next=kesu if kesu>(N-1): break print(ans) else: print(0)