#include <bits/stdc++.h>
using namespace std;
const int N=100000+10 ;
int last[30];
long long cnt=0;
int main()
{
string s;
cin>>s;
int n=s.length();
for(int i=1;i<=n;i++){
int j=s[i-1]-'a';//string s start from 0,it is haxi
cnt+=1ll *(i-last[j])*(n-i+1);
last[j]=i;
}
cout<<cnt<<endl;
return 0;
}