// clang-format off #include #include #include #include #include typedef long long int ll; #define FOR(i,a,b) for(ll i=(a);i<(b);i++) #define REP(i,n) for(ll i=0;i P; struct edge { ll to, cost; }; #define VMAX 100000 template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template T vgcd(T m, T n) {return std::gcd(m, n);} template T vgcd(T a, Args... args) {return vgcd(a, vgcd(args...));} // clang-format on int dx[]={1,-1,0,0}; int dy[]={0,0,1,-1}; int main(void) { ll ans = 0; ll N; string S; cin>>S; N=S.size(); reverse(ALL(S)); vector> A(N+1,vector(26)); REP(i,N){ A[i+1][S[i]-'A']++; } REP(i,N){ REP(j,26){ A[i+1][j]+=A[i][j]; } } REP(i,N-2){ REP(j,26){ if(j+'A'==S[i])continue; ans+=(A[N][j] - A[i][j]) * (A[N][j] - A[i][j]-1)/2; } } cout<