#include <bits/stdc++.h>
using namespace std;
char invalid_seq[1050000];
char seq[2050000];
int len;
const char str[3] = "LR";
double target;
double double_target;
double prob2() {
  double prob0 = 0.0;
  double prob1 = -target;
  double new_prob0, new_prob1;
  for (int i = len - 1; i >= 0; i--) {
    if (seq[i] == 'X') {
      new_prob0 = prob1 - target;
      new_prob1 = prob0 - target;
    } else if (seq[i] == 'L') {
      new_prob0 = prob1 + 1 - target;
      new_prob1 = max(prob0 - target, prob1 + double_target);
    } else {
      new_prob0 = max(prob1 - target, prob0 + double_target);
      new_prob1 = prob0 + 1 - target;
    }
    prob0 = new_prob0;
    prob1 = new_prob1;
  }
  return prob0;
}
double poss(int now, int place) {
  int prev_now = now;
  int prev_place = place;
  double res = 0.0;
  while (now < len && seq[now] != str[1 - place]) {
    if (seq[now] == 'X')
      res -= target;
    else
      res += 1 - target;
    now++;
    place = 1 - place;
  }
  printf("res = %f %d %d\n", res, prev_now, now);
  if (now < len) {
    double partial = poss(now + 1, 1 - place) - target;
    partial = max(partial, poss(now + 1, place) + double_target);
    res += partial;
  }
  if (now == len && place == 1) res -= target;
  printf("%f - %d %d = %f\n", target, prev_now, prev_place, res);
  return res;
}
int solve(int len) {
  double left = 0.0;
  double right = 1.0;
  for (int i = 0; i < 50; i++) {
    double mid = (left + right) / 2.0;
    target = mid;
    double_target = -target + 1 - target;
    if (prob2() >= 0.0)
      left = mid;
    else
      right = mid;
  }
  return (int)((left + right) * 50000000 + 0.000001);
}
int main() {
  scanf("%s", invalid_seq);
  int invalid_len = strlen(invalid_seq);
  for (int i = 0; i < invalid_len; i++) {
    if (i > 0 && invalid_seq[i] != 'X' && invalid_seq[i] == invalid_seq[i - 1])
      seq[len++] = 'X';
    seq[len++] = invalid_seq[i];
  }
  if (seq[len - 1] == seq[0] && seq[0] != 'X') {
    if (seq[0] == 'L')
      seq[len++] = 'X';
    else {
      for (int i = len - 1; i >= 0; i--) seq[i + 1] = seq[i];
      seq[0] = 'X';
      len++;
    }
  }
  seq[len] = 0;
  int res = 0;
  int ok = 0;
  for (int i = 0; i < len; i++)
    if (seq[i] != 'X') ok++;
  res = ok * (long long)50000000 / (len + (len % 2 == 0));
  res = max(res, solve(len));
  printf("%.6f\n", res / 1000000.0);
  return 0;
}
