#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    string s;
    cin >> s;
    long long int m = 0, pre = 0, r = 0;
    for (long long int i = 0; i < s.size(); i++) {
      if (s[i] == 'R') {
        r++;
        if (abs(i - pre) > m) {
          m = abs(i - pre);
        }
        if (r == 1) m++;
        pre = i;
      }
    }
    if (m == 0) m = s.size() + 1;
    long long int x = 0;
    for (long long int i = s.size() - 1; i >= 0; i--) {
      if (s[i] == 'L') {
        x++;
      } else
        break;
    }
    cout << max(m, x + 1) << endl;
  }
}
