#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
char s[maxn];
int num[256];
int main(){
	cin >> (s + 1);
	int n = strlen(s + 1);
	num[s[n]]++;
	long long ans = 0;
	for(int i = n - 1; i; i--){
		num[s[i]]++;
		if(s[i] == s[i + 1]){
			ans -= num[s[i]];
			for(int j = 'a'; j <= 'z'; j++) ans += num[j];
			for(int j = 'a'; j <= 'z'; j++){
				if(j == s[i]) continue;
				num[s[i]] += num[j];
				num[j] = 0;
			}
		}
	}
	cout << ans << endl;
	return 0;
}
#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;
}

