#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long MOD) {
  long long ans = 1;
  while (b) {
    if (b % 2) ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}
int main() {
  int t;
  int n, x, y, d;
  ios::sync_with_stdio(false);
  string a;
  cin >> n;
  cin >> a;
  int l = a.size();
  vector<int> v;
  v.push_back(-1);
  int fa = n + 12, fb = -23;
  for (int i = 0; i < l; i++) {
    if (a[i] == 'S') v.push_back(i);
    if (fa == n + 12 && a[i] == 'G') fa = i;
    if (a[i] == 'G') fb = i;
  }
  v.push_back(n);
  if (v.size() == 2) {
    cout << n << endl;
    return 0;
  } else {
    int ma = 0;
    for (int i = 1; i < v.size() - 1; i++) {
      int xa = v[i + 1] - v[i - 1] - 1;
      if (v[i + 1] > fb && v[i - 1] < fa) xa--;
      if (ma < xa) ma = xa;
    }
    cout << ma << endl;
  }
  return 0;
}
