#include using namespace std; const int N=2e5+10; double f[N][2],g[N][2],h[N][2]; char s[N]; int n; int main(){ scanf("%d",&n); scanf("%s",s); g[n-1][1]=1; f[n-1][1]=1; for (int i=n-2;i>=0;i--)if (s[i]=='.'){ if (i+1>n-1||s[i+1]=='#'){ h[i][0]+=1.0/3; h[i][1]+=1.0/3; }else{ h[i][0]+=h[i+1][0]/3+h[i+1][1]/3; h[i][1]+=h[i+1][1]/3; } if (i+2>n-1||s[i+2]=='#'){ h[i][0]+=1.0/3; h[i][1]+=1.0/3; }else{ h[i][0]+=h[i+2][0]/3+h[i+2][1]/3; h[i][1]+=h[i+2][1]/3; } double p=h[i][1]+1.0/3; double e=1.0/(1.0-p)*(h[i][0]+1.0/3)/(1.0-p); p=1.0/(1.0-p); double p1,e1; e1=(g[i+1][1]+g[i+1][0]+g[i+2][0]+g[i+2][1])/3; p1=(g[i+1][1]+g[i+2][1])/3; f[i][1]=p1*p; f[i][0]=p*e1+p1*e; g[i][1]=f[i][1]/3+p1; g[i][0]=f[i][0]/3+f[i][1]/3+e1; } printf("%.8lf\n",f[0][0]); }