#include <bits/stdc++.h>
using namespace std;
template <class _T>
inline void read(_T &_a) {
  bool f = 0;
  char _c = getchar();
  _a = 0;
  while (_c < '0' || _c > '9') {
    if (_c == '-') f = 1;
    _c = getchar();
  }
  while (_c >= '0' && _c <= '9') {
    _a = (_a << 3) + (_a << 1) - '0' + _c;
    _c = getchar();
  }
  if (f) _a = -_a;
}
int n, T, l, r, mid;
char str[200050];
inline bool check(int s) {
  int loc = 0, nloc;
  while (loc + s <= n) {
    nloc = loc;
    for (register int i = s; i; --i)
      if (str[loc + i] == 'R') {
        nloc = loc + i;
        break;
      }
    if (nloc == loc) return false;
    loc = nloc;
  }
  return true;
}
int main() {
  for (read(T); T; --T) {
    cin.getline(str + 1, 200001);
    n = strlen(str + 1);
    l = 1;
    r = n + 1;
    while (l < r) {
      mid = (l + r) >> 1;
      if (check(mid))
        r = mid;
      else
        l = mid + 1;
    }
    printf("%d\n", r);
  }
  return 0;
}
