#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int maxn = 1e6 + 10;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    vector<int> cnt(26);
    ll ans = 0;
    
    for (int i = n - 1; ~i; i--) {
        int m = n - i;
        int c = s[i] - 'a';
        cnt[c]++;
        if (i > n - 3) continue;
        if (s[i] == s[i + 1] && s[i] != s[i + 2]) {
            ans += m - cnt[c];
            for (int i = 0; i < 26; i++) cnt[i] = 0;
            cnt[c] = m;
        }
    }
    cout << ans;
}
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REPS(i,x) for(int i=1;i<=(int)(x);i++)
#define REPO(i,x) for(int i=x-1;i>=0;i--)
#define T int tc; cin>>tc;while(tc--)
#define READ   freopen("input.txt","r", stdin)
#define mem(a,b)     memset(a, b, sizeof(a))
#define lcm(a, b) ((a / __gcd(a, b) ) * b)
#define PI 2*acos(0.0)
#define pb push_back
#define eb emplace_back
#define ll long long
#define MAX 1e9
#define inf 1e18
#define MOD 1000000007
#define n0  cout<<"\n"
#define N 200001
int main()
{
    int n; string s;cin>>s; n=s.size(); int cnt[26]={0}; ll an=0;
    for(int i=n-1;i>=0;i--)
    { cnt[s[i]-'a']++;
        if(i<n-1)
        {
            if(s[i]==s[i+1])
            {
                 an+=n-i-cnt[s[i]-'a'];
                 memset(cnt,0,sizeof(cnt)); cnt[s[i]-'a']=n-i;
            }
        }
    } cout<<an<<endl;
}






