#include <bits/stdc++.h>
using namespace std;
const int Max = 2e6 + 10;
const int Mod = 1e9 + 7;
const int MAX = 2e18;
int main() {
  long long int x, j = 0, mx = 0, mx2 = 0, cnt = 0;
  bool f = 0, f2 = 0, f3 = 0;
  string s;
  cin >> x >> s;
  long long int ar[x + 5];
  memset(ar, 0, sizeof(ar));
  ;
  for (int i = 0; i < x; i++) {
    if (s[i] == 'G') {
      ar[j]++;
      f2 = 1;
      cnt++;
      if (f == 1) {
        f3 = 1;
      }
    } else {
      f = 1;
      if (i != x - 1) {
        j++;
      }
    }
  }
  if (f == 0) {
    cout << x << endl;
    ;
    return 0;
  }
  if (f2 == 0) {
    cout << 0 << endl;
    ;
    return 0;
  }
  if (f3 == 0) {
    cout << cnt << endl;
    ;
    return 0;
  }
  for (int i = 0; i < j + 1; i++) {
    if (ar[i + 1] == 0) {
      mx2 = max(mx2, ar[i]);
      ar[i] = 0;
      i++;
      continue;
    }
    mx2 = max(mx2, ar[i]);
    ar[i] = ar[i] + ar[i + 1];
    mx = max(mx, ar[i]);
  }
  if (mx2 > mx) {
    if (mx2 < cnt) {
      cout << mx2 + 1 << endl;
      ;
    } else {
      cout << mx2 << endl;
      ;
    }
  } else if (cnt > mx) {
    cout << mx + 1 << endl;
    ;
  } else {
    cout << mx << endl;
    ;
  }
  return 0;
}
