#include <bits/stdc++.h>
using namespace std;
int n, cnt, res, t, f[2][100001];
string s;
int main() {
  scanf("%d\n", &n);
  getline(cin, s);
  s = ' ' + s;
  for (int i = 1; i <= n; i++)
    if (s[i] == 'G') cnt++;
  for (int i = 1; i <= n; i++) {
    if (s[i] == 'G') {
      f[0][i] = f[0][i - 1] + 1;
      f[1][i] = f[1][i - 1] + 1;
    }
    if (s[i] == 'S') f[1][i] = max(f[1][i], f[0][i - 1] + 1);
    res = max(res, f[0][i]);
    if (f[1][i] - 1 < cnt) res = max(res, f[1][i]);
  }
  cout << res;
}
