#include <bits/stdc++.h>
using namespace std;
string s;
int n;
int g[100004], gp[100004];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> s;
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'G') {
      cnt++;
      g[i] = 1;
      gp[i] = 1;
    }
  }
  for (int i = 1; i < n; i++) {
    if (g[i - 1] && g[i]) g[i] += g[i - 1];
  }
  for (int i = n - 2; i >= 0; i--) {
    if (gp[i + 1] && gp[i]) gp[i] += gp[i + 1];
  }
  int ans = 0;
  for (int i = 1; i < n; i++) {
    ans = max(ans, (g[i - 1] + gp[i + 1] < cnt) ? (g[i - 1] + gp[i + 1] + 1)
                                                : g[i - 1] + gp[i + 1]);
  }
  cout << ans;
  return 0;
}
