#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  scanf("%d", &n);
  int temp = 0;
  vector<int> count;
  count.clear();
  int G = 0;
  while (n--) {
    char ch;
    scanf(" %c", &ch);
    if (ch == 'G') {
      temp++;
      G++;
    }
    if (ch == 'S') {
      count.push_back(temp);
      temp = 0;
    }
  }
  if (temp != 0) {
    count.push_back(temp);
  }
  if (count.size() == 0) {
    printf("0\n");
  } else {
    int max = count[0];
    if (count.size() > 1)
      for (int i = 0; i < count.size() - 1; i++) {
        if (count[i] + count[i + 1] > max) {
          max = count[i] + count[i + 1];
        }
      }
    if (G > max) {
      max++;
    }
    printf("%d\n", max);
  }
  return 0;
}
