#include <bits/stdc++.h>
using namespace std;
int main() {
  char str[100005];
  int n;
  int pre = 0, next = 0, sumG = 0, cnt = 0;
  scanf("%d", &n);
  getchar();
  for (int i = 0; i < n; i++) scanf("%c", &str[i]);
  for (int i = 0; i < n; i++) {
    if (str[i] == 'G') {
      next++;
      sumG++;
    } else {
      pre = next;
      next = 0;
    }
    cnt = max(cnt, pre + next + 1);
  }
  cnt = min(cnt, sumG);
  printf("%d\n", cnt);
  return 0;
}
