#include <bits/stdc++.h>
using namespace std;
const double Pi = acos(-1.0);
const int inf = 0x3f3f3f3f, Mod = 6, N = 2e5 + 3;
const long long INF = 1ll << 60;
inline long long qpow(long long a, long long b, long long mod = Mod) {
  long long ans = 1;
  while (b) {
    if (b & 1) ans = ans * a % mod;
    a = a * a % mod;
    b >>= 1;
  }
  return ans;
}
long long gcd(long long a, long long b) { return (b ? gcd(b, a % b) : a); }
long long lcm(long long a, long long b) { return a * b / (gcd(a, b)); }
std::pair<int, int> ed(int x, int y) {
  if (!y) {
    return {1, 0};
  }
  std::pair<int, int> a = ed(y, (x + y) % y);
  return {a.second, a.first - a.second * (x / y)};
}
bool cmp(std::pair<long long, long long> a, std::pair<long long, long long> b) {
  return a.first < b.first;
}
int main() {
  ios::sync_with_stdio(0);
  cout.tie(0), cin.tie(0);
  int n;
  string s;
  cin >> n >> s;
  int ans = 0, last = 0, now = 0, sum = 0;
  for (int i = 0; i < n; i++) {
    while (s[i] == 'G') now++, i++, sum++;
    ans = max(ans, now + last + 1);
    last = now;
    now = 0;
  }
  ans = min(ans, sum);
  cout << ans << '\n';
}
