#include <bits/stdc++.h>
#define ll long long 
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define vi vector<int>
#define vvi vector<vector<int> >
#define mii map<int,int>
#define pb push_back
#define pii pair<int,int>
#define mkp make_pair
#define scan(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define loop(i,n) for (int i = 0; i < n; i++)
#define loop1(i,n) for (int i = 1; i < n; i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PRECISION std::cout.unsetf ( std::ios::floatfield );std::cout.precision(15)
#define PI 3.14159265
#define endl '\n'
using namespace std;
int mod = 1000000007;
int m_inf = INT_MIN;

void init_code()
{
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif // ONLINE_JUDGE
}
 
void solve()
{
    string s;
    cin>>s;
    ll n=s.length();
    ll ans=0;
    vector<ll> cnt(26,0);
    for(ll i=n-1,j=0;i>0;--i,++j)
    {
        if(i<n-1 && i>0 && s[i]==s[i-1] && s[i]!=s[i+1])
        {
            ans+=j-cnt[s[i]-'a'];
            cnt.assign(26,0);
            cnt[s[i]-'a']=j;
        }
        cnt[s[i]-'a']++;
    }
    cout<<ans;
}
 
int main()
{
    init_code();
    int t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
}
// Hail god Yato
 
#include <bits/stdc++.h> 
using namespace std;
 
#define hs ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 1e18;
const ll MAX = 100001;
//
//
void solve(){
    string str;
    cin>>str;
    int arr[26] = {0};
    ll n = str.length(), ans = 0;
    for(int i = n-1; i >= 1; i--){
        if(str[i] == str[i-1]){
            ans += n-i-1-arr[str[i] - 'a'];
            // cout<<ans<<"\n";
            for(int i = 0; i < 26; i++)
                arr[i] = 0;
            arr[str[i] - 'a'] = n-i+1;
            --i;
        }
        else
            ++arr[str[i] - 'a'];
    }
    cout<<ans;
}
signed main(){ 
        hs;
        ll t;
        t=1;
        // cin>>t;
        for (int i=1; i<=t; i++){
                //cout<<"Case #"<<i<<": ";
                solve();
         }
        return 0; 
}