#include <bits/stdc++.h>
using namespace std;
template <typename T>
void __f(const char*, T&&);
template <typename T1, typename... T2>
void __f(const char*, T1&&, T2&&...);
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s;
    cin >> s;
    int n = s.length();
    int l = 1, h = n + 1;
    int ans = h;
    while (l <= h) {
      int m = (l + h) / 2;
      bool poss = false;
      int i = 0;
      while (true) {
        int p = -1;
        if (i >= n + 1) {
          poss = true;
          break;
        }
        for (int j = i + 1; j <= i + m; j++) {
          if (j >= n + 1) {
            poss = true;
            break;
          } else if (s[j - 1] == 'R') {
            p = j;
          }
        }
        if (poss) break;
        if (p == -1) break;
        i = p;
      }
      if (poss) {
        ans = min(ans, m);
        h = m - 1;
      } else {
        l = m + 1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
template <typename T>
void __f(const char* variable_name, T&& value) {
  cout << variable_name << ": " << value << endl;
}
template <typename T1, typename... T2>
void __f(const char* names, T1&& arg1, T2&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
