#include<iostream>
#include<math.h>
#include<string>
#include<stack>
using namespace std;
int solvea(){

  long long int ans=0;
  long long int s;
  cin>>s;
  for(long long int i=1LL;i<=s;i++){
    long long int hoge=0LL;
    for(long long int j=1LL;j*j*i<=s;j++){
      long long int temp=(s/(i*j));
      hoge+=temp;
    }
    long long int sq=sqrt(s/i);
    ans+=(2LL*hoge-sq*sq);
  }
  cout<<ans<<endl;
  return 0;
}

int solveb(){
  long long int a,b,c;
  cin>>a>>b>>c;
  int table[10][4]=
    {{0,0,0,0},
     {1,1,1,1},
     {6,2,4,8},
     {1,3,9,7},
     {6,4,6,4},
     {5,5,5,5},
     {6,6,6,6},
     {1,7,9,3},
     {6,8,4,2},
     {1,9,1,9}};
  a=a%10LL;
  b=b%4LL;
  if(b==0LL){
    cout<<table[a][0]<<endl;
  }
  else if(b==2LL){
    if(c>1){
      cout<<table[a][0]<<endl;
    }
    else{
      cout<<table[a][2]<<endl;
    }
  }
  else{
    if(c%2==0LL){
      cout<<table[a][1]<<endl;
    }
    else{
      cout<<table[a][b]<<endl;
    }
  }
  return 0;
}

class letter{
public:
  long long int itr;
  char ch;
  void print(){
    cout<<itr<<" "<<ch<<endl;
  }
};

int main(){
  string text;
  cin>>text;
  stack<letter> hoge;
  long long int ruiseki[26][200002]={};
  ruiseki[int(text[0]-97)][0]++;
  for(int i=0;i<26;i++){
    for(int j=1;j<text.size();j++){
      if(int(text[j])==i+97){
        ruiseki[i][j]=ruiseki[i][j-1]+1;
      }
      else{
        ruiseki[i][j]=ruiseki[i][j-1];
      }
    }
    ruiseki[i][text.size()]=ruiseki[i][text.size()-1];
  }

  for(int i=0;i<text.size()-1;i++){
    if(text[i]==text[i+1]){
      letter temp;
      temp.itr=i;
      temp.ch=text[i];
      hoge.push(temp);
    }
  }

  letter before;
  before.itr=text.size();
  before.ch='9';
  long long int ans=0LL;
  while(!hoge.empty()){
    letter now=hoge.top();
    hoge.pop();
    //now.print();
    //cout<<"ans="<<ans<<endl;
    if(before.itr!=now.itr+1){
      if(now.ch!=before.ch){
        ans+=(text.size()-before.itr);
      }
      ans+=((before.itr-now.itr-1)-(ruiseki[int(now.ch)-97][before.itr-1]-ruiseki[int(now.ch)-97][now.itr]));
    }
    before=now;
  }
  cout<<ans<<endl;
  return 0;
}

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<PII> VPI;
typedef vector<PLL> VPL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
#define fi first
#define se second
void YES(int a){
  if(a) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
void Yes(int a){
  if(a) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

//#include <atcoder/all>

//using namespace atcoder;
//typedef modint998244353 mint;


int main(){
  string S;
  cin>>S;
  int N=S.size();
  VVI X(26,VI(N+1));
  reverse(all(S));
  rep(i,N) X[S[i]-'a'][i+1]++;
  rep(i,26) rep(j,N+1){
    if(j) X[i][j]+=X[i][j-1];
  }
  reverse(all(S));
  VPI P(0);
  rep(i,N-1){
    if(S[i]==S[i+1]) P.pb(mp(S[i]-'a',i));
  }
  int tmp=-1;
  VPI Q(0);
  rep(i,P.size()){
    if(tmp!=P[i].fi){
      Q.pb(P[i]);
      tmp=P[i].fi;
    }
  }
  reverse(all(Q));
  ll ans=0;
  //for(auto e: Q) cout<<e.fi<<" "<<e.se<<endl;
  rep(i,Q.size()){
    if(!i){
      ans+=N-2-Q[i].se;
      ans+=2-(X[Q[i].fi][N-Q[i].se]-X[Q[i].fi][0]);
    }
    else{
      ans+=N-2-Q[i].se;
      //cout<<ans<<endl;
      ans+=2-(X[Q[i].fi][N-Q[i].se]-X[Q[i].fi][N-Q[i-1].se]);
    }
    //cout<<(X[Q[i].fi][N-Q[i].se]-X[Q[i-1].fi][0])<<" "<<ans<<endl;
  }
  cout<<ans<<endl;
}
