#include <bits/stdc++.h>
using namespace std;
const long long N = 1e5 + 10;
long long a[N], l[N], r[N];
signed main() {
  long long n;
  cin >> n;
  long long s = 0;
  long long answ = 0;
  long long cur = 0;
  for (long long i = 0; i < n; i++) {
    char x;
    cin >> x;
    if (x == 'G') {
      a[i] = 1;
      s++;
    };
    if (a[i] == 0)
      cur = 0;
    else
      cur++;
    answ = max(answ, cur);
  }
  for (long long i = 0; i < n; i++) {
    long long j = i + 1;
    for (; j < n && a[j]; j++)
      ;
    r[i] = j - i - 1;
    j = i - 1;
    for (; j >= 0 && a[j]; j--)
      ;
    l[i] = i - j - 1;
  }
  for (long long i = 0; i < n; i++) {
    if (a[i] == 0) {
      if (l[i] + r[i] == s) {
        answ = max(answ, l[i] + r[i]);
      } else {
        answ = max(answ, l[i] + r[i] + 1);
      }
    }
  }
  cout << answ;
  return 0;
}
