#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> tab;
bool check(int d) {
  int pt = -1;
  int ls = -1;
  while (pt + d < (int)s.size()) {
    ls = pt;
    pt = tab[pt + d];
    if (ls == pt) return false;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  int t;
  cin >> t;
  for (int al = 0; al < t; al++) {
    cin >> s;
    tab.resize(0);
    tab.resize(s.size() + 1);
    int last = -1;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'R') last = i;
      tab[i] = last;
    }
    int pt = 1, kon = s.size() + 1;
    while (kon - pt > 1) {
      int mid = (kon + pt) / 2;
      if (check(mid))
        kon = mid;
      else
        pt = mid;
    }
    if (!check(pt)) pt++;
    cout << pt << endl;
  }
}
