#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, count = 0, max = 0;
  bool flag = 0;
  string s;
  cin >> t;
  while (t--) {
    count = 0;
    max = 0;
    flag = 0;
    cin >> s;
    if (s.length() == 1) {
      if (s[0] == 'L') flag = 1;
    }
    if (s.length() > 1 && s[s.length() - 1] == 'L') {
      flag = 1;
    }
    for (int i = 0; i < s.length() - 1; i++) {
      if (s[i] == 'L') flag = 1;
      if (s[i] == s[i + 1] && s[i] == 'L') {
        count++;
      } else {
        if (count > max) max = count;
        count = 0;
      }
    }
    if (count > max) max = count;
    if (max == 0 && flag == 0)
      cout << 1 << "\n";
    else
      cout << max + 2 << "\n";
  }
}
