#include <bits/stdc++.h>
using namespace std;
long long int dp1[100008], dp2[100008];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int n;
  cin >> n;
  string temp;
  cin >> temp;
  char s[n + 2];
  for (long long int i = 1; i <= n; i++) s[i] = temp[i - 1];
  long long int gc = 0, sc = 0;
  dp1[0] = dp1[n] = 0;
  dp2[0] = dp2[n] = 0;
  for (long long int i = 1; i <= n; i++) {
    if (s[i] == 'G')
      gc++, dp1[i] = dp1[i - 1] + 1;
    else
      sc++, dp1[i] = 0;
  }
  if (gc == n) {
    cout << gc << endl;
    return 0;
  }
  if (gc == (n - 1)) {
    cout << n - 1 << endl;
    return 0;
  }
  if (gc == 0) {
    cout << "0" << endl;
    return 0;
  }
  for (long long int i = n; i >= 1; i--) {
    if (s[i] == 'G')
      dp2[i] = dp2[i + 1] + 1;
    else
      dp2[i] = 0;
  }
  long long int ans = INT_MIN;
  for (long long int i = 1; i <= n; i++) {
    long long int comp = dp1[i - 1] + dp2[i + 1] + 1;
    ans = max(ans, comp);
  }
  if (ans > gc) ans = gc;
  cout << ans << endl;
  return 0;
}
