#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using ul = unsigned long long;
using ii = pair<int, int>;
const ll mod7 = 1000000007, mod = 1000000000, OO = 0x3f3f3f3f;
const ld EPS = 1e-7;
double Pi = acos(-1);
const ld rad = Pi / 180.0;
ll power(ll x, ll y, ll p) {
  ll res = 1;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
ll nCr(ll n, ll m) { return (m == 0) ? 1 : n * nCr(n - 1, m - 1) / m; }
int n, x, y, d;
int dist(int x, int y) { return (abs(x - y) + (d - 1)) / d; }
int main() {
  string s;
  int n, x = 0, y = 0, z = 0, ans = 0;
  cin >> n;
  cin >> s;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'G') {
      x++;
      y++;
    } else {
      z = x;
      x = 0;
    }
    ans = max(ans, x + z + 1);
  }
  if (ans > y) ans = y;
  cout << ans << "\n";
  return 0;
}
