#include <bits/stdc++.h>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  while (k != 0) {
    int res = 0;
    string instr;
    cin >> instr;
    int n = instr.length();
    int tcount = 0;
    for (int i = 0; i < n; ++i) {
      if (instr[i] == 'L') {
        tcount++;
      } else {
        res = std::max(res, tcount);
        tcount = 0;
      }
    }
    res = max(res, tcount);
    cout << res + 1 << endl;
    k--;
  }
  return 0;
}
