#include<bits/stdc++.h>
#define int long long
using namespace std;
char s[500001];
int bb[30];
int vis,numm,ans;
char viss;

signed main()
{
	scanf("%s",s+1);
	viss='!';
	int len=strlen(s+1);
	for(int i=len;i>=3;i--)
	{
		if(s[i-1]==s[i-2]&&s[i]!=s[i-2])
		{
		 	if(s[i-1]!=viss)
		 	{
		 		ans+=(long long)(len-i+1-bb[s[i-1]-'a']);
			}
			else 
			{
				ans+=(long long)(vis-i-bb[s[i-1]-'a']);
			}
			//cout<<ans<<endl;
			viss=s[i-1];
		 	vis=i;
			for(int j=0;j<=26;j++) bb[j]=0;
		}
		else
		{
			bb[s[i]-'a']++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define endl "\n"
#define test ll txtc; cin>>txtc; while(txtc--)
typedef long long int ll;
typedef long double ld;
int main() {
    FIO;
    //test
    {
      string s; cin>>s;
      ll n=(ll)s.length();
      vector<vector<ll>>dp(n,vector<ll>(26,0));
      dp[0][s[0]-'a']++;
      for(ll i=1;i<n;i++){
          dp[i][s[i]-'a']++;
          for(ll j=0;j<26;j++){
              dp[i][j]+=dp[i-1][j];
          }
      }
      ll ans=0,last=n,op=-1;
      for(ll i=n-2;i>=1;i--){
          ll ch=s[i]-'a';
          if(s[i]==s[i-1]){
              if(op!=ch){
                  ans+=(n-last);
              }
              //cout<<ans<<endl;
              ans-=(dp[last-1][ch]-dp[i][ch]);
              //cout<<ans<<endl;
              ans+=(last-i-1);
              //cout<<ans<<endl;
              op=ch;
              last=i;
          }
      }
      cout<<ans<<endl;
    }
	return 0;
}
