#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    string cad;
    cin >> cad;
    int len = cad.length();
    int contL = 0, contR = 0;
    for (int i = 0; i < len; ++i) {
      if (cad[i] == 'L') contL++;
      if (cad[i] == 'R') contR++;
    }
    if (contL == len)
      cout << contL + 1 << "\n";
    else if (contR == len)
      puts("1");
    else {
      int d = 1, RB = 0;
      for (int i = 0; i < len; ++i) {
        if (cad[i] == 'L') {
          int c = 1, j = 0;
          for (j = i + 1; j < len; ++j) {
            if (cad[j] == 'L')
              c += 1;
            else
              break;
          }
          d = max(d, c + 1);
          i = j - 1;
        } else {
          if (d >= i - RB) {
            RB = i;
          } else
            d += 1;
        }
      }
      cout << d << "\n";
    }
  }
}
