#include <bits/stdc++.h>
using namespace std;
int n, a[100010], cnt, cont, sg, ans;
string s;
int main() {
  scanf("%d", &n);
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S') {
      a[++cnt] = cont;
      cont = 0;
      continue;
    }
    cont++;
    if (s[i] == 'G') {
      sg++;
    }
  }
  if (s[s.size() - 1] == 'G') {
    a[++cnt] = cont;
  }
  if (cnt == 1) {
    printf("%d\n", a[1]);
    return 0;
  } else {
    for (int i = 1; i < cnt; i++) {
      if (a[i] + a[i + 1] < sg) {
        ans = max(ans, a[i] + a[i + 1] + 1);
      } else {
        ans = max(ans, a[i] + a[i + 1]);
      }
    }
  }
  printf("%d\n", ans);
  return 0;
}
