#include <bits/stdc++.h>
using namespace std;
string s;
int n;
double f[2000010][2];
inline bool check(double mid) {
  f[0][0] = 0;
  f[0][1] = -mid;
  for (int i = 1; i <= n; i++) {
    f[i][0] = f[i - 1][1] - mid;
    f[i][1] = f[i - 1][0] - mid;
    if (s[i - 1] != 'X') {
      if (s[i - 1] == 'L')
        f[i][1] = max(f[i][1], f[i - 1][0] + 1 - mid);
      else
        f[i][0] = max(f[i][0], f[i - 1][1] + 1 - mid);
    }
    f[i][0] = max(f[i][0], f[i][1] - mid);
    f[i][1] = max(f[i][1], f[i][0] - mid);
  }
  return f[n][0] > 0;
}
char opt[1000010];
int main() {
  scanf("%s", opt + 1);
  n = strlen(opt + 1);
  for (int i = 1; i <= n; i++) {
    s.push_back(opt[i]);
    if (i != n && opt[i] != 'X' && opt[i] == opt[i + 1]) s.push_back('X');
  }
  if (opt[1] == opt[n] && opt[n] != 'X') {
    if (opt[1] == 'L')
      s = s + 'X';
    else
      s = 'X' + s;
  }
  n = s.size();
  double L = 0, R = 1;
  while (R - L > 1e-10) {
    double mid = (L + R) / 2;
    if (check(mid))
      L = mid;
    else
      R = mid;
  }
  int x = (L + 1e-10) * 100000000;
  printf("%d.%06d\n", x / 1000000, x % 1000000);
  return 0;
}
