#include "bits/stdc++.h"

using namespace std;
using LL = long long;

constexpr int N = 1e5 + 5;

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	
	string s;
	cin >> s;

	int n = s.size();
	int cnt[26];
	memset(cnt, 0, sizeof cnt);

    LL res = 0;

	for (int i = n - 1; i > 0; i--) {
		if (s[i] == s[i - 1]) {
			res += n - i - 1 - cnt[s[i] - 'a'];
			memset(cnt, 0, sizeof cnt);
			cnt[s[i] - 'a'] = n - i - 1;
		}
		cnt[s[i] - 'a']++;
	}

	cout << res << endl;
}



//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")

#include<bits/stdc++.h>
#include<string.h>
using namespace std;
#define pb          push_back
#define all(v)      v.begin(),v.end()
#define ya          cout<<"Yes"<<endl;
#define no          cout<<"No"<<endl;
#define ff          first
#define sc          second
#define inf         999999999
#define pi          3.14159265359
#define printv(v)   for(auto x:v)cout<<x<<' ';cout<<endl;
#define takev(v)    for(auto &x:v)cin>>x;
inline  int         random(int a=1,int b=10)
{
    return a+rand()%(b-a+1);
}
typedef long long ll;
inline ll           lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
//#define see(x)  cout<<endl<<#x<<" : "<<(x)<<endl;
#define see(args...) \
{ \
    string _s = #args; replace(_s.begin(), _s.end(), ',', ' ');\
    stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);\
}
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr<< *it << " = " << a <<",\n"[++it==istream_iterator<string>()];
    err(it, args...);
}
#define scc(n) scanf("%lld",&n);
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const int N=3e6+9,mod=998244353;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    string s;
    cin>>s;
    ll i,a,ans=0,n=s.size(),last=1;
    map<char,int>last_seen;
    for(i=n-1;i>=0;i--)
    {
        if(i-2>=0 && s[i]!=s[i-1] && s[i-1]==s[i-2])
        {
//            see(s[i-1],last_seen[s[i-1]])
            ans += (n-i) - last_seen[s[i-1]];
            for(char j='a';j<='z';j++)last_seen[j]=0;
            last_seen[s[i-1]]=n-i;
        }
        else
        last_seen[s[i]]++;

    }
/// anerroroccucced -> 12
    cout<<ans<<endl;

    return 0;
}

