#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const int ninf = -(1e9 + 7);
bool solve(string input, int d) {
  int curr_pos = -1;
  int n = input.size();
  while (curr_pos < n) {
    bool right_found = false;
    for (int i = curr_pos + 1; i <= curr_pos + d; ++i) {
      if (i >= n) {
        return true;
      }
      if (input[i] == 'R') {
        right_found == true;
        curr_pos = i;
      }
    }
    if (right_found == false) {
      return false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int tc;
  cin >> tc;
  while (tc--) {
    string input;
    cin >> input;
    int low = 1, high = input.size();
    int ans = inf;
    while (low <= high) {
      int mid = low + (high - low) / 2;
      bool can_jump = solve(input, mid);
      if (can_jump == true) {
        ans = mid;
        high = mid - 1;
      } else {
        low = mid + 1;
      }
    }
    if (ans == inf) {
      cout << input.size() + 1 << "\n";
    } else {
      cout << ans << "\n";
    }
  }
  cout << "\n";
}
