Problem: Jack has become a soldier now. Unfortunately, he has trouble with the drill. Instead of marching beginning with the left foot and then changing legs with each step, as ordered, he keeps repeating a sequence of steps, in which he sometimes makes the wrong steps or — horror of horrors! — stops for a while. For example, if Jack uses the sequence 'right, left, break', when the sergeant yells: 'Left! Right! Left! Right! Left! Right!', Jack first makes a step with the right foot, then one with the left foot, then he is confused and stops for a moment, then again - this time according to the order - starts with the right foot, then uses the left foot, then - to the sergeant's irritation - he stops to catch his breath, to incorrectly start with the right foot again... Marching this way, Jack will make the step that he is supposed to in the given moment in only one third of cases.

When the officers convinced him he should do something about it, Jack decided to modify the basic sequence of steps that he repeats. However, in order not to get too tired, he has decided that the only thing he'll do is adding any number of breaks in any positions of the original sequence (a break corresponds to stopping for the duration of one step). Of course, Jack can't make a step on the same foot twice in a row, if there is no pause between these steps. It is, however, not impossible that the sequence of steps he used so far is incorrect (it would explain a lot, actually).

Help Private Jack! Given the sequence of steps he keeps repeating, calculate the maximal percentage of time that he can spend marching correctly after adding some breaks to his scheme.

Input

The first line of input contains a sequence consisting only of characters 'L', 'R' and 'X', where 'L' corresponds to a step with the left foot, 'R' — with the right foot, and 'X' — to a break. The length of the sequence will not exceed 106.

Output

Output the maximum percentage of time that Jack can spend marching correctly, rounded down to exactly six digits after the decimal point.

Examples

Input

X


Output

0.000000


Input

LXRR


Output

50.000000

Note

In the second example, if we add two breaks to receive LXXRXR, Jack will march: LXXRXRLXXRXRL... instead of LRLRLRLRLRLRL... and will make the correct step in half the cases. If we didn't add any breaks, the sequence would be incorrect — Jack can't step on his right foot twice in a row.

Solution (in JAVA):

Solution:

import java.util.*;
import java.math.*;
import static java.lang.Character.isDigit;
import static java.lang.Character.isLowerCase;
import static java.lang.Character.isUpperCase;
import static java.lang.Math.*;
import static java.math.BigInteger.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Character.isDigit;

public class Main{
    static void debug(Object...os){
        System.err.println(deepToString(os));
    }
    
    void run(){
//      Random r=new Random(12094112098292L);
//      for(int o=0;o<100;o++) {
//          System.out.print(".");
////            int n=r.nextInt(1000)+1;
//          int n=1000000;
//          StringBuilder sb=new StringBuilder();
////            String s="";
//          while(sb.length()<n) {
//              char c="XRL".charAt(r.nextInt(3));
//              if(sb.length()==0 || c=='X' || sb.charAt(sb.length()-1)!=c) {
//                  sb.append(c);
//              }
//          }
//          String s=sb.toString();
//          if(s.charAt(0)!='X' && s.charAt(0)==s.charAt(s.length()-1)) {
//              if(r.nextBoolean())s="X"+s;
//              else s="X"+s;
//          }
////            debug(1);
//          double a=calc(s.toCharArray());
////            double b=calcStupid(s.toCharArray());
////            debug(a,b);
////            assert Math.abs(a-b)<1e-9 : s;
//      }
//      System.out.println();
//      System.out.println("OK");
        
        
        char[] cs=next().toCharArray();
        StringBuilder b=new StringBuilder();
        for(int i=0;i<cs.length;i++) {
            if(i>0 && cs[i-1]==cs[i] && cs[i]!='X') {
                b.append('X');
            }
            b.append(cs[i]);
        }
        String s=b.toString();
        double res=solve(s);
        System.out.printf("%.06f\n",((long)((res+1e-9)*100000000L))/1000000.0);
    }
    private double solve(String s) {
        double res;
        if(s.charAt(0)!='X' && s.charAt(0)==s.charAt(s.length()-1)) {
            res = max(calc((s+"X").toCharArray()) , calc(("X"+s).toCharArray()));
        }
        else res = calc(s.toCharArray());
        return res;
    }
    
    private double calc(char[] cs){
        int n=cs.length;
        char tmp='L';
        int same=0;
        int add=0;
        int canFit=0;
        for(int i=0;i<n;) {
            if(cs[i]=='X') {
                i++;
                tmp=nxt(tmp);
                continue;
            }
            int j=i;
            while(j<n && cs[j]!='X')j++;
            if(j-i>=2) {
                same += j-i;
                if(tmp!=cs[i]) {
                    add++;
                }
                tmp=nxt(cs[j-1]);
                i=j;
            }else {
                if(cs[i]==tmp) {
                    same++;
                    tmp=nxt(tmp);
                    i=j;
                }else {
                    tmp=nxt(tmp);
                    while(j<n && cs[j]=='X') {
                        j++;
                        tmp=nxt(tmp);
                    }
                    if(j==n) {
                        if(tmp=='L') {
                            canFit++;
                        }else {
                            add++;
                            same++;
                            tmp=nxt(tmp);
                        }
                    }else {
                        if(cs[j]==tmp) {
                            canFit++;
                        }else {
                            add++;
                            same++;
                            tmp=nxt(tmp);
                        }
                    }
                    i=j;
                }
            }
        }
        if(tmp!='L')add++;
//      debug(same,add,canFit);
        n+=add;
        while(canFit>0 && ((double)same/n) < (double)(same+1)/(n+2)) {
            same++;n+=2;canFit--;
        }
        return (double)same/n;
    }

    private char nxt(char c){
        if(c=='L')return 'R';
        else if(c=='R')return 'L';
        throw new IllegalStateException();
    }
    
    private double calcStupid(char[] cs) {
        int n=cs.length;
        int[][][] dp=new int[n+1][n+2][2];
        String S="LR";
        for(int i=0;i<n+1;i++)for(int j=0;j<n+2;j++)for(int k=0;k<2;k++)dp[i][j][k]=Integer.MIN_VALUE;
        dp[0][0][0]=0;// i,add,L -> same 
        for(int i=0;i<n;i++)for(int j=0;j<n+1;j++)for(int k=0;k<2;k++)if(dp[i][j][k]>Integer.MIN_VALUE) {
            if(cs[i]=='X')dp[i+1][j][1^k] = max(dp[i+1][j][1^k],dp[i][j][k]);
            else {
                int t=S.indexOf(cs[i]);
                if(t==k) {
                    dp[i+1][j][1^k] = max(dp[i+1][j][1^k],dp[i][j][k] + 1);
                }else {
                    dp[i+1][j][1^k] = max(dp[i+1][j][1^k],dp[i][j][k]);
                    dp[i+1][j+1][k] = max(dp[i+1][j+1][k],dp[i][j][k]+1);
                }
            }
        }
        double res=0;
        for(int i=0;i<n;i++)for(int j=0;j<2;j++)if(dp[n][i][j]>0) {
            res=max(res,(double)dp[n][i][j]/(n+i+j));
        }
        return res;
    }

    int nextInt(){
        try{
            int c=System.in.read();
            if(c==-1) return c;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=System.in.read();
                if(c==-1) return c;
            }
            if(c=='-') return -nextInt();
            int res=0;
            do{
                res*=10;
                res+=c-'0';
                c=System.in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }
    
    long nextLong(){
        try{
            int c=System.in.read();
            if(c==-1) return -1;
            while(c!='-'&&(c<'0'||'9'<c)){
                c=System.in.read();
                if(c==-1) return -1;
            }
            if(c=='-') return -nextLong();
            long res=0;
            do{
                res*=10;
                res+=c-'0';
                c=System.in.read();
            }while('0'<=c&&c<='9');
            return res;
        }catch(Exception e){
            return -1;
        }
    }
    
    double nextDouble(){
        return Double.parseDouble(next());
    }
    
    String next(){
        try{
            StringBuilder res=new StringBuilder("");
            int c=System.in.read();
            while(Character.isWhitespace(c))
                c=System.in.read();
            do{
                res.append((char)c);
            }while(!Character.isWhitespace(c=System.in.read()));
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }
    
    String nextLine(){
        try{
            StringBuilder res=new StringBuilder("");
            int c=System.in.read();
            while(c=='\r'||c=='\n')
                c=System.in.read();
            do{
                res.append((char)c);
                c=System.in.read();
            }while(c!='\r'&&c!='\n');
            return res.toString();
        }catch(Exception e){
            return null;
        }
    }
    public static void main(String[] args){
        new Main().run();
    }
}