#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  scanf("%d", &t);
  while (t--) {
    string s;
    cin >> s;
    int n = s.length();
    vector<int> v(n, 0);
    v[0] = (s[0] == 'L');
    int ans = (s[0] == 'L');
    for (int i = 1; i < n; i++) {
      if (s[i] == 'L') {
        v[i] = v[i - 1] + 1;
        ans = max(ans, v[i]);
      }
    }
    cout << ans + 1 << endl;
  }
  return 0;
}
