#include <bits/stdc++.h>
using namespace std;
const int xx = 2e5;
int a[xx], b[xx];
char ar[xx];
int main() {
  int n;
  while (~scanf("%d", &n)) {
    memset(a, 0, sizeof(a));
    memset(ar, 0, sizeof(ar));
    bool f = true;
    scanf("%s", ar);
    int k = 0, p = 0, ma = 0;
    for (int i = 0; i < n; ++i) {
      if (i == 0) {
        while (ar[i] == 'S') i++;
      }
      if (ar[i] == 'G' && !p) {
        a[k]++;
        ma = max(ma, a[k]);
      } else if (ar[i] == 'G' && p == 1) {
        a[k]++;
        a[k + 1]++;
        ma = max(ma, max(a[k], a[k + 1]));
      } else if (ar[i] == 'S') {
        p++;
        f = true;
        while (ar[i + 1] == 'S') {
          p++;
          f = false;
          i++;
        }
        if (ar[i + 1] != 'G') continue;
        if (p == 2 && f) {
          k++;
          p = 1;
        } else if (!f) {
          k += 2;
          p = 0;
        }
      }
    }
    if (k == 0) {
      printf("%d\n", ma);
    } else
      printf("%d\n", ma + 1);
  }
}
