#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline bool umin(T1 &a, const T2 &b) {
  return a > b ? a = b, true : false;
}
template <typename T1, typename T2>
inline bool umax(T1 &a, const T2 &b) {
  return a < b ? a = b, true : false;
}
inline int read() {
  int x = 0, ng = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') ng = 1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return ng ? -x : x;
}
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const int seed = 20040305;
int n;
string s;
int l[100100], r[100100];
int cnt = 0;
int main() {
  scanf("%d", &n);
  cin >> s;
  for (int i = 0; i < n; i++) {
    if (i != 0) l[i] = l[i - 1];
    if (s[i] == 'G')
      l[i]++;
    else
      l[i] = 0;
  }
  for (int i = n - 1; i >= 0; i--) {
    if (i != n - 1) r[i] = r[i + 1];
    if (s[i] == 'G')
      r[i]++;
    else
      r[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    if (s[i] == 'G') cnt++;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int res = 0;
    if (i != 0) res += l[i - 1];
    if (i != n - 1) res += r[i + 1];
    res++;
    umin(res, cnt);
    umax(ans, res);
  }
  printf("%d", ans);
}
