#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    string s;
    cin >> s;
    vector<int> arr(s.size());
    int l = 0;
    int r = s.size() + 1;
    while (r - l > 1) {
      vector<int> used(s.size());
      int mid = (r + l) / 2;
      int cur = mid - 1;
      while (cur < int(s.size()) && used[cur] == false && cur >= 0) {
        used[cur] = 1;
        if (s[cur] == 'L') {
          cur--;
        } else {
          cur += mid;
        }
      }
      if (cur >= int(s.size())) {
        r = mid;
      } else {
        l = mid;
      }
    }
    cout << r << endl;
  }
}
