#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long n;
  string s;
  cin >> n >> s;
  vector<long long> gl(n), gr(n);
  for (long long i = 1; i < (long long)n; i++)
    if (s[i - 1] == 'G') gl[i] += gl[i - 1] + 1;
  for (long long i = n - 2; i >= 0; i--)
    if (s[i + 1] == 'G') gr[i] += gr[i + 1] + 1;
  long long c = 0, cg = count((s).begin(), (s).end(), 'G');
  for (long long i = 0; i < (long long)n; i++) {
    long long c1 = min(gl[i] + gr[i] + 1, cg);
    c = max(c, c1);
  }
  cout << c;
  return 0;
}
