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