#include <bits/stdc++.h>
using namespace std;
void solve() {
  int T;
  cin >> T;
  for (int cas = 1; cas <= T; ++cas) {
    string str;
    cin >> str;
    int sz = str.size();
    int ans = sz + 1;
    auto possible = [&](int index) {
      bool flag = true;
      for (int i = 0, k; i < sz; i++) {
        int u = i + index;
        if (u > sz) {
          return true;
        }
        flag = true;
        for (k = i; k < u and k < sz; ++k) {
          if (str[k] == 'R') {
            flag = false;
            i = k;
          }
        }
        if (flag) {
          return false;
        }
      }
      if (flag) {
        return false;
      }
      return true;
    };
    auto check = [&]() {
      int lo = 1, hi = sz + 1;
      int mid = sz;
      while (lo <= hi) {
        mid = (lo + hi) / 2;
        if (possible(mid)) {
          hi = mid - 1;
        } else {
          lo = mid + 1;
        }
      }
      ans = lo;
    };
    check();
    cout << ans << '\n';
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}
