#include <bits/stdc++.h>
using namespace std;
long long n, i, j, dem = 0, s, maxx = -90000, g;
string a;
int main() {
  scanf("%lld\n", &n);
  getline(cin, a);
  a = " " + a;
  for (i = 1; i <= n; i++) {
    if (a[i] == 'S')
      s++;
    else
      g++;
  }
  i = 1;
  while (i <= n) {
    dem = 0;
    while (a[i] == 'S') {
      i++;
    }
    j = i;
    while (a[j] == 'G') {
      j++;
    }
    dem = j - i;
    i = j + 1;
    if (s > 0 && g - dem > 0) {
      j = i;
      while (a[j] == 'G') j++;
      dem += j - i;
      dem++;
    }
    maxx = max(maxx, dem);
  }
  if (maxx > g) maxx = g;
  cout << maxx;
}
