#include <bits/stdc++.h>
using namespace std;
const int N = 200000 + 10;
int l[N], r[N];
int n, x, y, d, t;
int main() {
  scanf("%d", &n);
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'G') cnt++;
  }
  l[0] = 0;
  for (int i = 1; i < n; i++) {
    if (s[i - 1] == 'G') {
      l[i] = l[i - 1] + 1;
    } else {
      l[i] = 0;
    }
  }
  r[n - 1] = 0;
  for (int i = n - 2; i >= 0; i--) {
    if (s[i + 1] == 'G') {
      r[i] = r[i + 1] + 1;
    } else {
      r[i] = 0;
    }
  }
  int mx = 0;
  for (int i = 0; i < n; i++) {
    mx = max(mx, min(l[i] + r[i] + 1, cnt));
  }
  printf("%d\n", mx);
  return 0;
}
