#include using namespace std; #define fi first #define se second #define pb push_back using vi = vector ; using ll = long long; using vl = vector ; using pii = pair ; const ll mod = 998244353; //~ const ll mod = 1e9 + 7; ll qpow(ll a, ll b, ll m = mod) { ll r = 1, t = a; for(; b; b /= 2) { if(b & 1) r = r * t % m; t = t * t % m; } return r; } const int N = 2e5 + 11; const int M = 100; int n; string s; double a[M + 2][N], b[M + 2][N], f[M + 2][N]; int main() { ios::sync_with_stdio(0); int n; cin >> n; cin >> s; s = '#' + s + "##"; for(int j = n - 1; j >= 1; j --) { for(int i = min(n - 1, j + M - 1); i >= j; i --) { for(int t : {1, 2}) if(s[i + t] == '#') { a[i - j][j] += 1.0 / 3; } else { a[i - j][j] += a[i - j + t][j] / 3; b[i - j][j] += b[i - j + t][j] / 3; } if(i != j) b[i - j][j] += f[0][i] / 3; else a[i - j][j] += 1.0 / 3; b[i - j][j] += 1; //~ cout << i << ' ' << j << ' ' << a[i - j][j] << ' ' << b[i - j][j] << '\n'; } f[0][j] = b[0][j] / (1 - a[0][j]); for(int i = min(n, j + M - 1); i > j; i --) f[i - j][j] = a[i - j][j] * f[0][j] + b[i - j][j]; } cout << fixed << setprecision(8) << f[0][1] << '\n'; }