#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pi (3.141592653589)
#define mod 1000000007
#define float double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rrep(i, n) for(int i=n-1;i>=0;i--)
#define rep(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);

vector<int> primeFactors(int n)  
{    
    vector<int> ans;
    for(int i=1;i*i<=n;i++)
    {
        if(n%i == 0)
        {
            ans.push_back(i);
            if(n/i != i)
                ans.push_back(n/i);
        }
    }
    return ans;
}  
bool perfectCube(int N)
{
    int cube_root;
    cube_root = round(cbrt(N));
 
    // If cube of cube_root is equals to N,
    // then print Yes Else print No
    if (cube_root * cube_root * cube_root == N) {
        // cout << "Yes";
        return 1;
    }
    else {
        // cout << "NO";
        return 0;
    }
}
void solve()
{
    int t=1;
    // cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        map<char,int> mp;
        int ans = 0;
        int n = s.size();
        mp[s[n-1]] += 1;
        for(int i=n-2;i>=0;i--)
        {
            if(s[i] == s[i+1])
            {
                int minus = 0;
                if(mp.find(s[i]) != mp.end())
                    minus = mp[s[i]];

                ans += (n-1-i) - minus;
                mp.clear();
                mp[s[i]] = n-i;
            }
            else
            {
                mp[s[i]] += 1;
            }
            
        }
        cout<<ans;
    }
}

int32_t main(){

    solve();
    return 0;
}

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

#define ll long long
#define int ll
#define ld long double
#define pii pair<int, int>
#define f first
#define s second
#define readl(_s) getline(cin, (_s));
#define boost() cin.tie(0); cin.sync_with_stdio(0)

string s;
int cnt[26];

int32_t main() {
    boost();

    cin >> s;
    int ans = 0;
    reverse(s.begin(), s.end());
    //cnt[s[0] - 'a']++, cnt[s[1] - 'a']++;
    for (int i = 2; i < s.size(); i++) {
        cnt[s[i - 2] - 'a']++;
        if (s[i] == s[i - 1] && s[i] != s[i - 2]) {
            int id = s[i] - 'a';
            ans += i - 1 - cnt[id];
            for (int j = 0; j < 26; j++) cnt[j] = 0;
            cnt[id] = i - 1;
        }
    }
    printf("%lld\n", ans);

    return 0;
}