#include using namespace std; int main() { string S; cin >> S; int N = S.size(); long long Ans = 0; for (int i = 'A'; i <= 'Z'; i++) { int MM_Count = 0, A_Count = 0; for (int j = 0; j < N; j++) { if (S.at(j) == i) { Ans += (long long)MM_Count * (MM_Count - 1) / 2 * A_Count; A_Count = 0; MM_Count++; } else A_Count++; } Ans += (long long)MM_Count * (MM_Count - 1) / 2 * A_Count; } cout << Ans << endl; }