#include <bits/stdc++.h>
#define LL long long
#define ft first
#define sd second
#define mp(x,y) make_pair(x,y)
#define int LL
using namespace std;
//const int N   = ;
//const int mod = ;
const int INF =numeric_limits<int >::max();
#define For(n) for (int i=1;i<=n;++i)
#define rep(i,n) for (int i=1;i<=n;++i)
#define repp(i,x,y) for (int i=x;i<=y;++i)
void read(int &x)
{
	x=0;
	char ch=getchar();
	int f=1;
	while (!isdigit(ch)) (ch=='-'?f=-1:0),ch=getchar();
	while ( isdigit(ch)) x=x*10+ch-'0',ch=getchar();
	x*=f;
}

int solve(int x)
{
	int tmp=0;
	for (int i=1;i<=x;++i)
	{
		int j=x/(x/i);
		tmp+=(j-i+1)*(x/i);
		i=j;
	}
	return tmp;
}
int ans,K;
int qsm(int a,int b,int mod)
{
	int tmp=1;
	while (b)
	{
		if (b&1) tmp=tmp*a%mod;
		b>>=1;
		a=a*a%mod;
	}
	return tmp;
}
int a,b,c,cnt[30];
char s[2000000+2];
signed main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	int nxt=n+1;
	cnt[s[n]-'a']++;
	cnt[s[n-1]-'a']++;
	for (int i=n-2;i>=1;--i)
	{
		if (s[i]==s[i+1]&&s[i+1]!=s[i+2])
		{
			ans+=n-i-cnt[s[i]-'a'];
			memset(cnt,0,sizeof(cnt));
			cnt[s[i]-'a']=n-i;
		} 
		cnt[s[i]-'a']++;
	}
	printf("%lld",ans);
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ostream &operator<<(ostream &os, const vector<lli> &x){
    os << "{";
    for(int i = 0; i < x.size(); i++){
        if(i < x.size()-1) os << x[i] << ", ";
        else os << x[i];
    }
    os << "}";
    return os;
}

int main(void){
    string s;
    cin >> s;
    lli n = s.size();
    lli ans = 0;
    char last = '!';
    vector<lli> count(26);
    for(int i = n-1; i >= 0; i--){
      char c = s[i];
      count[c-'a']++;
      if(last == c){
        lli tot = 0;
        for(int j = 0; j < 26; j++){
          char now = 'a'+j;
          lli val = count[now-'a'];
          count[now-'a'] = 0;
          if(now == c) continue;
          tot+=val;
        }
        ans += tot;
        count[c-'a'] = n-i;
        last = '!';
      }
      last = c;
    }
    cout << ans << endl;
    return 0;
}
