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