N=int(input()) S=input() T='ACGT' ans=0 for t in T: if t in S: ans=max(ans,N-S[::-1].find(t)) print(ans)