#include <bits/stdc++.h>
int dx[] = {0, -1, 0, 1, -1, 1, -1, 1};
int dy[] = {-1, 0, 1, 0, 1, -1, -1, 1};
const int MOD = 1e9 + 7, N = 2e5 + 5;
const double pi = acos(-1);
using namespace std;
int n, l[N], r[N];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n;
  string s;
  cin >> s;
  int g = 0;
  for (int i = 0; i < (int)(s).size(); i++) {
    if (s[i] == 'G') {
      g++;
      l[i] = 1;
      if (i) l[i] += l[i - 1];
    }
  }
  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'G') {
      r[i] = 1;
      if (i < n - 1) r[i] += r[i + 1];
    }
  }
  int ans = 0;
  for (int i = 0; i < (int)(s).size(); i++) {
    if (s[i] == 'S') {
      int cur = 1;
      if (i) cur += l[i - 1];
      if (i < n - 1) cur += r[i + 1];
      ans = max(ans, cur);
    }
  }
  ans = min(g, ans);
  if (g == n) ans = n;
  cout << ans;
  return 0;
}
