#include <iostream>
#include <bits/stdc++.h>
#define pb push_back
#define ll long long int

using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    ll n=s.length(),c=0,li=n;
    char pri='0';
    for(ll i=n-2;i>=0;i--)
    {
        if(s[i]==s[i+1] && s[i]!=s[i+2])
        {
            char o=s[i];
           for(ll j=i+2;j<li;j++)
           if(s[j]!=o)
           c++;
           if(s[i]!=pri)
           c+=n-li;
           pri=s[i];
           li=i;
        }

    }
    cout<<c<<"\n";
}
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i, n) for(ll i=n-1;i>=0;--i)
#define rep1(i, n) for(ll i=1; i<=n; ++i)
#define repitr(itr,mp) for(auto itr=mp.begin();itr!=mp.end();++itr)
#define ALL(a) (a).begin(),(a).end()

template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

using namespace std;
using ll  = long long;
using ld = long double;
using ull = unsigned long long;
using pll = pair<ll, ll>;

const ll MOD  = 998244353;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;
const double PI = 3.1415926535897932384626;

ll mod(ll a, ll m){return (a + m) % m;}

int main(){
    string s;
    cin >> s;

    reverse(ALL(s));

    vector<ll> cnt(26, 0);
    ll ans = 0;
    rep(i, (int)s.size()){
        if(i && s[i-1] == s[i]){
            rep(j, 26)if(j != s[i] - 'a'){
                ans += cnt[j];
                cnt[j] = 0;
            }
            cnt[s[i] - 'a'] = i+1;
        }
        else cnt[s[i]-'a']++;
    }

    cout << ans << endl;
}