#include <bits/stdc++.h>
using namespace std;
const int MAX = 2 * 10e5;
int main() {
  int t, d, k;
  bool f;
  string s;
  cin >> t;
  for (int i = 0; i < t; i++) {
    d = 0;
    f = 0;
    k = 0;
    cin >> s;
    for (unsigned int j = 0; j < s.length(); j++) {
      if (s[j] == 'L') {
        k += 1;
      } else {
        if (f == 0) {
          f = 1;
        }
        k += 1;
        if (k > d) {
          d = k;
        }
        k = 0;
      }
    }
    if (k + 1 > d) {
      d = k + 1;
    }
    if (f == 0) {
      cout << s.length() + 1 << endl;
    } else {
      cout << d << endl;
    }
  }
}
