#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> l(n);
  vector<int> r(n);
  int k = 0;
  for (int i = 0; i < n; i++)
    if (s[i] == 'G') k++;
  if (s[0] == 'G') l[0] = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] == 'G') l[i] = l[i - 1] + 1;
  }
  if (s[n - 1] == 'G') r[n - 1] = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] == 'G') r[i] = r[i + 1] + 1;
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'G') continue;
    int temp = 1;
    if (i > 0) temp += l[i - 1];
    if (i < n - 1) temp += r[i + 1];
    ans = max(ans, temp);
  }
  ans = min(ans, k);
  if (k == n) ans = n;
  cout << ans;
  return 0;
}
