#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> silver, gold;
  int g = 0, mxg = -1;
  ;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'S') {
      gold.push_back(g);
      if (g > mxg) mxg = g;
      g = 0;
      silver.push_back(i);
    } else
      g++;
  }
  if (g) gold.push_back(g);
  if (g > mxg) mxg = g;
  for (int i = 0; i < silver.size(); i++) {
    if (i == gold.size() - 1) break;
    if (gold[i] > 0 && gold[i + 1]) {
      int g = gold[i] + gold[i + 1];
      bool found = 0;
      for (int p = 0; p < gold.size(); p++) {
        if (p != i && p != i + 1 && gold[p] > 0) {
          found = true;
          break;
        }
      }
      if (found) g++;
      if (g > mxg) mxg = g;
    } else if (gold[i] > 0) {
      int g = gold[i];
      bool found = 0;
      for (int p = 0; p < gold.size(); p++) {
        if (p != i && gold[p] > 0) {
          found = true;
          break;
        }
      }
      if (found) g++;
      if (g > mxg) mxg = g;
    } else if (gold[i + 1] > 0) {
      int g = gold[i + 1];
      bool found = 0;
      for (int p = 0; p < gold.size(); p++) {
        if (p != i + 1 && gold[p] > 0) {
          found = true;
          break;
        }
      }
      if (found) g++;
      if (g > mxg) mxg = g;
    }
  }
  cout << mxg << endl;
}
