#include using namespace std; typedef long long ll; typedef pair PP; //#define MOD 1000000007 #define MOD 998244353 #define INF 2305843009213693951 //#define INF 810114514 #define PI 3.141592653589 #define setdouble setprecision #define REP(i,n) for(ll i=0;i<(n);++i) #define OREP(i,n) for(ll i=1;i<=(n);++i) #define RREP(i,n) for(ll i=(n)-1;i>=0;--i) #define ALL(v) (v).begin(), (v).end() #define GOODBYE do { cout << "-1" << endl; return 0; } while (false) #define MM <<" "<< #define Endl endl #define debug true #define debug2 false int main(void){ //cin.tie(nullptr); //ios::sync_with_stdio(false); string S; cin >> S; ll N = S.size(); //0~iまでで文字jはいくつあるか ll dp1[26] = {}; //0~iまでで重複する文字jはいくつあるか ll dp2[26] = {}; ll dp2sum = 0; ll Ans = 0; REP(i,N){ if(i==0){ dp1[S[i]-'A']++; continue; } /*ll tmp1[26], tmp2[26]; REP(j,26){tmp1[j]+=dp1[j];} REP(j,26){tmp2[j]+=dp2[j];}*/ int c = S[i]-'A'; dp2[c]+=dp1[c]; dp2sum+=dp1[c]; dp1[c]++; Ans += (dp2sum-dp2[c]); /*REP(j,26){cout << (char)('A'+j) << " ";}cout << endl; REP(j,26){cout << dp1[j] << " ";}cout << endl; REP(j,26){cout << dp2[j] << " ";}cout << endl; cout << Ans << endl << endl;*/ /*swap(dp1,tmp1); swap(dp2,tmp2);*/ } cout << Ans << endl; return 0; }