#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e5 + 1;
int MOD = 1e9 + 7;
const int INF = 1e9;
const long long LINF = 1e18;
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a;
  int ans = 0;
  bool ok = true;
  bool all_s = true;
  vector<int> pref(n);
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      if (s[i] == 'G')
        pref[i] = 1;
      else
        pref[i] = 0;
    } else {
      if (s[i] == 'G')
        pref[i] = 1 + pref[i - 1];
      else
        pref[i] = pref[i - 1];
    }
  }
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'S') {
      ok = false;
      int l = 0, r = 0;
      bool k1 = false, k2 = false;
      int j = i - 1;
      while (j >= 0 && s[j] == 'G') {
        l++;
        j--;
      }
      if (j > 0) {
        if (pref[j - 1]) k1 = true;
      }
      j = i + 1;
      while (j < n && s[j] == 'G') {
        r++;
        j++;
      }
      if (j < n - 1 && pref[n - 1] - pref[j] > 0) k2 = true;
      if (k1 || k2)
        ans = max(ans, r + l + 1);
      else
        ans = max(ans, r + l);
    } else
      all_s = false;
  }
  if (ok) ans = n;
  if (all_s) ans = 0;
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
}
