#include<bits/stdc++.h>
// no of bits to store no 2e5 is 19
// 2e5 ka 5 times square root lene se 2 or 3 ke pass pahunch jate hai
using namespace std;

#define int               long long
#define mod               1000000007
#define MOD               1000000007
#define MAX               1000000000
#define inf               1e18
#define ff                first
#define ss                second
#define mp                make_pair
#define pb                push_back
#define pii               pair<int,int>
#define mii               map<int, int>
#define all(x)            (x).begin(), (x).end()
#define fill(a,b)         memset(a, b, sizeof(a))
#define sp(x,y)           fixed<<setprecision(y)<<x
#define setbits(x)        __builtin_popcount(x)
#define fast_in_out       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define ll                long long

//   powermod(a,b,m) ==  powermod(a,b%(m-1),m)  when m is prime fermat's theorem a^(p-1) %p=1 p is prime
int powermod(int a,int b,int c) //  gives (a^b)%c
{
    int ans = 1,tempans=a%c;
    while(b>0)
    {
        if(b&1==1)
        {
            ans=(ans*tempans)%c;
        }
             tempans=(tempans*tempans)%c;
             b=b>>1;
    }
    return ans;
}

int modinverse(int a,int m)   // gives a inverse wrt m and m is prime
{
    return powermod(a,m-2,m);
}

ll add(ll x, ll y) {
   x += y;
   if (x >= mod) return x - mod;
   return x;
}
ll sub(ll x, ll y) {
   x -= y;
   if (x < 0) return x + mod;
   return x;
}
ll mult(ll x, ll y) {
   return (x * y) % mod;
}
// my template                                              m
// prime factorization                                      pf
// ncr and factorials                                       ncr
// matrix exponentiation of fibonacci series in log(n)      matexpofib
// cycles in a graph                                        cycle
// prime factorization in log(n)                            spf



void solve()
{
   string s;
   cin>>s;
   int ans =0;
   int n=s.length();
   int a[26]={0};
   for(int i=n-1;i>=1;i--)
   {
      if(s[i]==s[i-1])
      {
         int re= n-i-1;
         int fr= a[s[i]-'a'];
         ans+=(re-fr);
         for(int j=0;j<26;j++)
            a[j]=0;
         a[s[i]-'a']=n-i;

      }
      else
      {
         a[s[i]-'a']++;
      }
   }
   cout<<ans<<endl;



}


int32_t main()
{
  fast_in_out;

  int t=1;//cin>>t;
  int count=0;


   while(t--)
   {
       count++;
       solve();
   }
}

#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <tuple>
#include <utility>
#include <functional>
#include <set>
#include <map>
#include <bitset>
#include <list>
#include<iomanip>

using namespace std;
using ll = long long;
using ULL = unsigned long long;
using pll = std::pair<ll, ll>;
using vi = std::vector<int>;
using vl = std::vector<ll>;
using vb = std::vector<bool>;
using db = double;
using vdb = std::vector<db>;
using qlg= std::priority_queue<ll, vl, std::greater<ll> > ; //ascending
using qll= std::priority_queue<ll, vl, std::less<ll> > ; // descending
using qdg= std::priority_queue<db, vdb, std::greater<db> > ; //ascending
using qdl= std::priority_queue<db, vdb, std::less<db> > ; // descending
template<class T>
using vv = std::vector<std::vector<T> >;


#define REPL(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FORL(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define REP(i, n) FORL(i, 0, n)

#define MREP(i, n) for (ll i= (ll)(n)-1; i>=0; i-- )
#define MFOR(i, a, b) for (ll i = (ll)(b)-1; i >= (ll)(a); i--)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rreps(i, a, b) for (int i = (int)(b)-1; i >= (int)(a); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bit(n) (1LL << (n))
#define INF pow(10, 10)

void change(ll id, vl &counts, ll &Times)
{
    ll num = 0;
    REP(i, 26)
    {
        if(i != id)
        {
            num += counts[i];
            counts[i] = 0;
        }
    }
    counts[id] += num;
    Times += num;
}

int main(void)
{

    ll  N, K;
    string Str;

    cin >> Str;

    ll Len = Str.size();

    vl counts(26, 0);

    ll Time_Max = 0;
    MFOR(i, 1, Len)
    {
        ll id = Str[i]-'a';
        if(Str[i] == Str[i-1])
        {
            change(id, counts, Time_Max);
            // cout << i << " " << Str[i] << ", "<< Time_Max << endl;
            counts[id] ++;
        }
        else
        {
            counts[id] ++;
        }
    }

    cout << Time_Max << endl;


    return 0;
}
