#include <bits/stdc++.h>
using namespace std;
const int maxn = 4e5 + 5;
int len, m, k;
int a[maxn], c[maxn];
int ans, tmp, cnt;
int flag;
char s[maxn];
bool ok[maxn];
int jud(int d) {
  int i = 0;
  while (i <= len) {
    int j = min(i + d, len + 1);
    if (j == len + 1) return 1;
    while (j > i && s[j] == 'L') j--;
    if (j == i) return 0;
    i = j;
  }
  return 0;
}
int main() {
  int T, cas = 1;
  scanf("%d", &T);
  while (T--) {
    scanf("%s", s + 1);
    len = strlen(s + 1);
    int ans = len + 1;
    int l = 1, r = len + 1;
    while (l < r) {
      int m = (l + r) >> 1;
      if (jud(m)) {
        r = m;
        ans = m;
      } else
        l = m + 1;
    }
    printf("%d\n", ans);
  }
  return 0;
}
