#include using namespace std; typedef long long ll; int main(){ string S; cin >> S; int l = S.length(); vector dp(l+1,0); map ser; ser[S[0]]++; ser[S[1]]++; if(S[0] == S[1] && S[2] != S[1]){ dp[3] = 1; } ll next = 0; for(int i=4;i<=l;i++){ int x = ser[S[i-2]]; if(x != 0){ if(S[i-1] == S[i-2]){ dp[i] += x; }else{ dp[i]+=x+next; next = 0; } } ser[S[i-2]]++; int y = ser[S[i-1]]; if(y >= 2){ ll down = y*(y-1)/2; dp[i]+=dp[i-1]-down; next = down; }else{ dp[i] += dp[i-1]; } } for(int i=1;i<=l;i++){ dp[i] += dp[i-1]; } cout << dp[l] << endl; }