local s = io.read() local n = #s local t = {} for i = 1, 26 do t[i] = {} end for i = 1, n do local b = s:sub(i, i):byte() - 96 table.insert(t[b], i) end -- inv sort for i = 1, 26 do local tn = #t[i] local htn = math.floor(tn / 2) for j = 1, htn do t[i][j], t[i][tn + 1 - j] = t[i][tn + 1 - j], t[i][j] end end local val = 0 for i = 1, 26 do if 0 < #t[i] then val = val + n + 1 - t[i][#t[i]] end end local cnt = 0 for i = 1, n do cnt = cnt + val local b = s:sub(i, i):byte() - 96 if t[b][#t[b]] == i then val = val - (n + 1 - t[b][#t[b]]) table.remove(t[b]) if 0 < #t[b] then val = val + (n + 1 - t[b][#t[b]]) end end end local all = n * (n + 1) / 2 print(string.format("%.10f", cnt / all))