#int(input()) #map(int, input().split()) #list(map(int, input().split())) N = int(input()) s = input() a = "AGCT" ans = 0 for i in range(N-1, -1, -1): if s[i] in a: ans = i+1 break print(ans)