#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template <typename T>  using ordered_set =
tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define ll           long long
#define rep(i,j,n)   for(int i=j;i<n;i++)
#define scn(a)       scanf("%d",&a)
#define scns(a,b)    scanf("%d %d",&a,&b)
#define print(a)     printf("%d\n",a)
#define vec          vector<int>
#define pb           emplace_back    
#define pairs        pair<int,int>
#define f            first
#define s            second
#define all(v)       v.begin(),v.end()
#define mem(a,b)     memset(a,b,sizeof(a))
#define inf          1e18
const int mod = 1e9+7;
const int N = 5e5+5;

int n;

int main()
{
    int test; test = 1;

    while(test--)
    {
        string s1; cin>>s1;

        s1 = "0" + s1;

        int n = (int)s1.size()-1, st = -1;

        vector<pair<int,int>> v1;

        int mp[n+5][26]; memset(mp, 0, sizeof mp);

        for(int i = 1; i <= n; ++i)
        ++mp[i][s1[i]-'a'];

        for(int i = 1; i <= n; ++i)
        for(int j = 0; j < 26; ++j)
        mp[i][j] += mp[i-1][j];

        for(int i = 1; i <= n-2;)
        {
            if(s1[i] == s1[i+1] && s1[i] != s1[i+2])
            v1.pb(i, s1[i]-'a'), i += 2;
            else
            ++i;
        }

        if((int)v1.size() == 0)
        {
            print(0);

            continue;
        }

        // cout<<v1.size()<<endl;
        
        ll ans = 0; reverse(all(v1));

        int ind = -1, prev = -1;

        // cout<<n<<endl;

        for(auto [st, ch]:v1)
        {
            // cout<<st<<" ch "<<ch<<endl;

            if(prev == -1)
            {
                // cout<<ch<<endl;

                int val = mp[n][ch] - mp[st+1][ch];

                // cout<<val<<endl;

                ans += n - (st + 1) - val;
            }
            else
            {
                if(prev == ch)
                {
                    // cout<<prev<<" "<<ind<<endl;

                    int val = mp[ind-1][ch] - mp[st+1][ch];

                    // cout<<"VAL "<<val<<endl;
                    
                    ans += n - (st + 1) - val - (n - ind + 1);
                }
                else
                {
                    int val = mp[ind-1][ch] - mp[st+1][ch];

                    ans += n - (st + 1) - val;
                }
            }

            prev = ch, ind = st;

            // cout<<ans<<endl;
        }

        printf("%lld\n",ans);
    }

    return 0;
}
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define REPA(i,j) for(int i=1;i<=j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
#define all(a) a.begin(),a.end()
using namespace std;
const int INF=1<<30;
inline void read(int &x){
//	short neg=1;
	x=0;
	char c=getchar();
	/*while(c<'0'||c>'9'){
		if(c=='-')neg=-1;
		c=getchar();
	}*/
	while(c>='0'&&c<='9'){
		x=(x<<3)+(x<<1)+(c^48),c=getchar();
	}
//	x*=neg;
}
string s;
int n;
int sum[256]={0};
int main(void){
	cin>>s;
	n=s.size();
	reverse(all(s));
	ll ans=0;
	sum[(int)s[0]]++;
	for(int i=1;i+1<n;i++){
		if(s[i]==s[i+1]){
			ans+=i-sum[(int)s[i]];
			for(char c='a';c<='z';c++)sum[(int)c]=0;
			sum[(int)s[i]]=i+2;
			i++;
		}
		else{
			sum[(int)s[i]]++;
		}
	} 
	cout<<ans<<endl;
	return 0;
}
