#include using namespace std; using ll = long long; using P = pair; #define fix(x) fixed << setprecision(x) #define asc(x) x, vector, greater #define rep(i, n) for(ll i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() templatebool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;} templatebool chmax(T&a, const T&b){if(a> s; vector cnt(26,0); int n = s.size(); ll ans = 0; rep(i,n) ans += (cnt[s[i]-'A']++) * (n-1-i); rep(i,26) ans -= (cnt[i]-2)*(cnt[i]-1)*cnt[i]/6; cout << ans << '\n'; return 0; }