s = gets.chomp n = s.size prev = [-1] * 256 ans = 0 s.chars.each_with_index do |c, i| ans += (n - i) * (i - prev[c.ord]) prev[c.ord] = i end puts ans.to_f / (n * (n + 1) / 2)