#include <bits/stdc++.h>
using namespace std;
double a, b, c, d, l, m, r, p = 1e-10;
int i, x;
void get(char* g, int n) {
  l = 0, r = 1;
  while (r - l >= p) {
    for (m = (l + r) / 2, a = -m, b = 0, i = 1; i <= n; i++, a = c, b = d) {
      if (g[i] == g[i - 1] && g[i] != 'X')
        c = max(a - 2 * m, b - 3 * m) + (g[i] == 'L'),
        d = max(a - 3 * m, b - 2 * m) + (g[i] == 'R');
      else
        c = max(a - 2 * m, b - m) + (g[i] == 'L'),
        d = max(a - m, b - 2 * m) + (g[i] == 'R');
    }
    if (max(a - m, b) > 0)
      l = m;
    else
      r = m;
  }
  x = (l + p) * 1e8;
}
char g[1000005];
int n;
int main() {
  scanf("%s", g + 1), n = strlen(g + 1);
  if (g[1] != g[n] || g[n] == 'X')
    get(g, n);
  else if (g[1] == 'L')
    g[n + 1] = 'X', get(g, n + 1);
  else
    *g = 'X', get(g - 1, n + 1);
  printf("%d.%06d", x / 1000000, x % 1000000);
  return 0;
}
