n = int(input()) s = list(input()) for i in range(n - 1, -1, -1): if s[i] in "AGCT": print(i + 1) break else: print(0)