#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>
#include <iomanip>
#include <limits>
#include<tuple>
#include<algorithm>
#include<set>

using namespace std;
typedef long long int ll;
// ll 
int main(){
    string s;
    cin >> s;
    // vector<pair<int,char>> block(26,{-1,'0'});
    int mae=(-1);
    ll point=0;
    char ima='0';
    for(int i=0;i<s.size()-1;i++){
        if(s.at(i)==s.at(i+1) && s.at(i)!=ima){
            if(mae!=(-1))point+=(s.size()-i);
            mae=i;
            ima=s.at(i);
        }else{
            if(ima!='0'){
                if(ima!=s.at(i)){
                    point++;
                }
            }
        }
    }
    if(s.at(s.size()-1)!=ima && ima!='0')point++;
    cout << point << endl;
    return 0;
}
#ifndef Local
#pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("popcnt,abm,mmx,avx2")
#endif
#include <bits/stdc++.h>

using namespace std;

#define popCnt(x) (__builtin_popcountll(x))
#define sz(x) ((int)(x.size()))
#define all(v) begin(v), end(v)
#define rall(v) rbegin(v), rend(v)
#define rep(i, l, r) for (int i = l; i < r; ++i)
using Long = long long;
using Double = double;
using vi = vector<int>;

template <class U, class V>
istream& operator>>(istream& is, pair<U, V>& p) {
  is >> p.first >> p.second;
  return is;
}
template <class T>
istream& operator>>(istream& is, vector<T>& v) {
  for (auto& x : v) {
    is >> x;
  }
  return is;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (auto& x : v) {
    os << x << " ";
  }
  return os;
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#ifdef Local
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#else
#define endl '\n'
#endif

  string s;
  cin >> s;
  Long res = 0;
  vector<int> cnt(26);
  for (int i = sz(s) - 1; i >= 0; --i) {
    ++cnt[s[i] - 'a'];
    if (i + 1 < sz(s) && s[i] == s[i + 1]) {
      res += sz(s) - i - cnt[s[i] - 'a'];
      cnt.assign(26, 0);
      cnt[s[i] - 'a'] = sz(s) - i;
    }
  }
  cout << res << endl;
  return 0;
}