#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int

// quoted from beet-aizu
template <typename T,typename E, typename F, typename G, typename H>
struct LazySegmentTree{
    //using F = function<T(T,T)>;
    //using G = function<T(T,E)>;
    //using H = function<E(E,E)>;
    int n,height;
    F f;
    G g;
    H h;
    T ti;
    E ei;
    vector<T> dat;
    vector<E> laz;
    LazySegmentTree(F f,G g,H h,T ti,E ei):
        f(f),g(g),h(h),ti(ti),ei(ei){}

    void init(int n_){
        n=1;height=0;
        while(n<n_) n<<=1,height++;
        dat.assign(2*n,ti);
        laz.assign(2*n,ei);
    }
    void build(const vector<T> &v){
        int n_=v.size();
        init(n_);
        for(int i=0;i<n_;i++) dat[n+i]=v[i];
        for(int i=n-1;i;i--)
            dat[i]=f(dat[(i<<1)|0],dat[(i<<1)|1]);
    }
    inline T reflect(int k){
        return laz[k]==ei?dat[k]:g(dat[k],laz[k]);
    }
    inline void eval(int k){
        if(laz[k]==ei) return;
        laz[(k<<1)|0]=h(laz[(k<<1)|0],laz[k]);
        laz[(k<<1)|1]=h(laz[(k<<1)|1],laz[k]);
        dat[k]=reflect(k);
        laz[k]=ei;
    }
    inline void thrust(int k){
        for(int i=height;i;i--) eval(k>>i);
    }
    inline void recalc(int k){    
        while(k>>=1)
            dat[k]=f(reflect((k<<1)|0),reflect((k<<1)|1));
    }
    void update(int a,int b,E x){
        thrust(a+=n);
        thrust(b+=n-1);
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1){
            if(l&1) laz[l]=h(laz[l],x),l++;
            if(r&1) --r,laz[r]=h(laz[r],x);
        }
        recalc(a);
        recalc(b);
    }
    void set_val(int a,T x){
        thrust(a+=n);
        dat[a]=x;laz[a]=ei;
        recalc(a);
    }
    T query(int a,int b){
        thrust(a+=n);
        thrust(b+=n-1);
        T vl=ti,vr=ti;
        for(int l=a,r=b+1;l<r;l>>=1,r>>=1) {
            if(l&1) vl=f(vl,reflect(l++));
            if(r&1) vr=f(reflect(--r),vr);
        }
        return f(vl,vr);
    }
};

signed main() {

  string s; cin >> s;
  int n = s.size();
    
  using P = pair<int, int>;
  auto f = [](P a, P b){ return P(a.first + b.first, a.second + b.second); };
  auto g = [](P a, int b){ return P(a.second * b, a.second); };
  auto h = [](int a, int b){ return b != INT_MAX ? b : a; };
  using SG = LazySegmentTree<P, int, decltype(f), decltype(g), decltype(h)>;
  vector<SG> sg(26, SG(f, g, h, P(0, 0), INT_MAX));
  for (int i = 0; i < 26; i++) {
    sg[i].build(vector<P>(n, P(0, 1)));
  }
  // sg.build(vector<P>(n, P(0, 1)));

  //  for(int i = 0; i < q; i++){
  //      int com; cin >> com;
  //      if(!com){
  //          int s, t, x; cin >> s >> t >> x;
  //          sg.update(s, t + 1, x);
  //      }else{
  //          int s, t; cin >> s >> t;
  //          cout << sg.query(s, t + 1).first << endl;
  //      }   
  //  }
  
  for (int i = 0; i < s.size(); i++) {
    sg[s[i] - 'a'].update(i, i + 1, 1);
  }


  int ans = 0;
  for (int i = s.size() - 1; i >= 0; i--) {
    if (s[i] != s[i + 1]) continue;
    ans += n - i - sg[s[i] - 'a'].query(i, n).first;

    for (int j = 0; j < 26; j++) {
      if ((int)(s[i] - 'a') == j) {
        sg[j].update(i, n, 1);
      } else {
        sg[j].update(i, n, 0);
      }
    }
  }

  cout << ans << endl;
  return 0;
}


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             4
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

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

//insert,find_by_order,order_of_key,lower_bound,upper_bound;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define deb(...)
#endif

  
//////////////////////////////code//////////////////////////////

const int N = 200;

int power(int a, int b = mod - 2) {
    
  int x = 1 % mod;
  a %= mod;
  b %= mod - 1;
  while (b) {
      
    if (b & 1) x = (x * a)%mod;
    a = (a * a)%mod;
    b >>= 1;
    
  //  deb(x);
  }
 
  
  return x;
  
}



void solve()
{

      int ans = 0;

      string s;
      cin >> s;

      int n = sz(s);
      
      char prev = '/';
      
      int f = 0;
      int fr[26] = {0};

      for(int i = n - 1;i >= 0; i--)
      {   
            if(s[i] == s[i + 1])
            {     
                  for(int j = 0;j < 26; j++)
                  {     
                        if(j == (int)(s[i] - 'a'))
                          continue;

                        ans += fr[j];
                        fr[s[i] - 'a'] += fr[j];
                        fr[j] = 0;
                  }
            }

            fr[s[i] - 'a']++;
      }

      db(ans)
}

int32_t main()
{   

    LETS_GET_SCHWIFTY;

     #ifndef ONLINE_JUDGE
     freopen("INP.txt", "r", stdin);
     freopen("out.txt", "w", stdout);
     #endif  


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

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values

