#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n, d, c, g, res, ok, pos;
  string s;
  cin >> s;
  n = s.length();
  s = 'R' + s;
  vector<bool> a(n + 1);
  d = 1;
  c = res = n + 1;
  while (d <= c) {
    g = d + c >> 1;
    ok = 1;
    pos = 0;
    fill(a.begin(), a.end(), 0);
    while (pos < n + 1) {
      if (a[pos]) {
        ok = 0;
        break;
      }
      a[pos] = 1;
      if (s[pos] == 'R')
        pos += g;
      else
        --pos;
    }
    if (ok) {
      res = g;
      c = g - 1;
    } else {
      d = g + 1;
    }
  }
  cout << res << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
