from collections import defaultdict def transformString(S): counter = defaultdict(lambda : 0) max_consecutive_count = 0 for i in range(len(S)): if i == 0 or S[i] != S[i-1]: if S[i] == 'C': counter[S[i]] += 1 else: max_consecutive_count = max(max_consecutive_count,counter[S[i]]) counter[S[i]] += 1 elif S[i] == 'C': counter[S[i]] += 1 elif S[i] == 'T': counter[S[i]] += 1 if counter[S[i]] == 0: max_consecutive_count = max(max_consecutive_count,counter[S[i]]) return max_consecutive_count N = int(input()) s = input() print(transformString(s))