CF1082B Vova and Trophies

题目描述

你现在有 $n$ 枚奖牌,每枚奖牌为金牌或银牌。这些奖牌现在按顺序排成一排。现在你可以调换任意一对奖牌的位置,求金牌最长连续段。

输入格式

第一行一个整数 $n$ $(2\le n\le 10^5)$ . 第二行一行字符串,表示你的奖牌。 ( $\texttt{G}$ 表示金牌,$\texttt{S}$ 表示银牌)

输出格式

输出一个整数表示答案。

说明/提示

In the first example Vova has to swap trophies with indices $ 4 $ and $ 10 $ . Thus he will obtain the sequence "GGGGGGGSGS", the length of the longest subsegment of golden trophies is $ 7 $ . In the second example Vova can make no swaps at all. The length of the longest subsegment of golden trophies in the sequence is $ 4 $ . In the third example Vova cannot do anything to make the length of the longest subsegment of golden trophies in the sequence greater than $ 0 $ .