#include <bits/stdc++.h>
using namespace std;
int n, a[100005], sum, ans, t1, t2;
char ch[100005];
int gets() {
  int v = 0;
  bool f = 0;
  char ch;
  while (!isdigit(ch)) {
    f |= ch == '-';
    ch = getchar();
  }
  while (isdigit(ch)) {
    v = (v << 3) + (v << 1) + ch - 48;
    ch = getchar();
  }
  return f ? -v : v;
}
int main() {
  n = gets();
  scanf("%s", ch + 1);
  for (int i = 1; i <= n; i++) a[i] = (ch[i] == 'G' ? 1 : 0), sum += a[i];
  for (int i = 1; i <= n + 1; i++) {
    if (!a[i]) {
      ans = max(ans, i - t2 - 1);
      t2 = t1;
      t1 = i;
    }
  }
  ans = min(ans, sum);
  printf("%d\n", ans);
  return 0;
}
