#include <bits/stdc++.h>
using namespace std;
int n, cnt, lft[100002], rite[100002];
string s;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cin >> n >> s;
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (s[i] == 'G') {
      cnt++;
      lft[i] = 1;
      if (i != 0) {
        lft[i] += lft[i - 1];
      }
    }
  }
  for (int(i) = (n - 1); ~i; --(i)) {
    if (s[i] == 'G') {
      rite[i] = 1;
      if (i != n - 1) {
        rite[i] += rite[i + 1];
      }
    }
  }
  int ans = 0;
  for (int(i) = 0; (i) < (n); ++(i)) {
    if (s[i] == 'S') {
      int tmp = 1;
      if (i > 0) {
        tmp += lft[i - 1];
      }
      if (i + 1 < n) {
        tmp += rite[i + 1];
      }
      ans = max(ans, tmp);
    }
  }
  ans = min(ans, cnt);
  if (cnt == n) ans = cnt;
  cout << ans << "\n";
  return 0;
}
