#include using namespace std; using ll = long long; int main() { string s; ll n; cin >> s; n = s.size(); vector> pos(26); for(auto &i: pos)i.push_back(-1); for(ll i = 0; i < n; i++) { pos[s[i] - 'a'].push_back(i); } for(auto &i: pos)i.push_back(n); ll unit = n * (n + 1) / 2; ll sum = 0; for(ll i = 0; i < 26; i++) { ll cur = unit; ll m = pos[i].size(); for(ll j = 0; j < m - 1; j++) { ll num = pos[i][j+1] - pos[i][j]; cur -= num * (num - 1) / 2; } sum += cur; } cout << fixed <