#include <bits/stdc++.h>
#define pii pair<int, int>
#define ld long double
#define ll long long
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s;
    cin >> s;
    int n = s.length();
    int cnt[300];
    memset(cnt, 0, sizeof(cnt));
    
    int lastIdx = n;
    char lastChar = '-';
    ll ans = 0;
    for (int i = n - 1; i >= 0; i--) {
        if (i != n - 1 && s[i] == s[i + 1]) {
            cnt[s[i]]--;
            if (lastChar == s[i]) ans += lastIdx - i - 2 - cnt[s[i]];
            else ans += n - i - 2 - cnt[s[i]];
            lastIdx = i;
            lastChar = s[i];
            memset(cnt, 0, sizeof(cnt));
        } else {
            cnt[s[i]]++;
        }
    }
    
    cout << ans << "\n";
    
    
    
    
}


//jai baba loknath
#include<bits/stdc++.h>
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less
using namespace std;
using namespace __gnu_pbds;
typedef       long long int      ll;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);
#define       RESET(a, b)        memset(a, b, sizeof(a))
#define       gcd(a, b)          __gcd(a, b)
#define       MX                 200005
#define       MOD                1000000007
#define       inf                ll(1e18)
#define       PI                 acos(-1.0)
#define       eps                1e-9
#define       Yes                cout<<"Yes"<<endl;
#define       YES                cout<<"YES"<<endl;
#define       No                 cout<<"No"<<endl;
#define       NO                 cout<<"NO"<<endl;
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
inline ll mod(ll a, ll m){ if(a<0) return ((a%m)+m)%m; else if(a<m) return a; else return (a%m); }

ll LCM(ll a, ll b)
{
   return (a / __gcd(a, b)) * b;
}
//for vector of pair
/*bool cmp(pair<int,int>a, pair<int,int>b)
{
   if(a.first==b.first)
      return a.second<b.second;
   else
      return a.first<b.first;
}*/
//for priority queue of pair
class cmp {
public:
	bool operator()(pair<ll,ll> A, pair<ll,ll> B)
	{
		if(A.first==B.first)
         return A.second>B.second;
      else
         return A.first<B.first;
	}
};
ll sum[27][MX];
int main(void)
{
   optimize
   RESET(sum,0);
   ll t,n,m,k,x,y;
   vector<ll> v,v1,v2;
   vector< pair<ll,ll> > p,p1,p2;
   set<ll> st;
   map<ll,ll> mp;
   priority_queue<ll> pq;
   priority_queue< ll,vector<ll>,greater<ll> > lpq;
   priority_queue< pair<ll,ll> > phpq;
   priority_queue< pair<ll,ll>,vector<pair<ll,ll>>,cmp > phpqcmp;
   priority_queue< pair<ll,ll>,vector< pair<ll,ll> >,greater< pair<ll,ll> > > plpq;
   string s;
   //cin>>t;
   //while(t--)//for(ll tc=1;tc<=t;tc++)
   {
      cin>>s;
      for(char j='a';j<='z';j++)
      {
         for(ll i=0;i<s.size();i++)
         {
            if(i==0)
            {
               if(s[i]==j)
                  sum[j-'a'][i]=1;
               else
                  sum[j-'a'][i]=0;
            }
            else if(s[i]==j)
               sum[j-'a'][i]=sum[j-'a'][i-1]+1;
            else
               sum[j-'a'][i]=sum[j-'a'][i-1];
         }
      }
      /*for(char j='a';j<='z';j++)
      {
         for(ll i=0;i<s.size();i++)
         {
            cout<<sum[j-'a'][i]<<" ";
         }
         cout<<endl;
      }*/
      ll pos=s.size()-1,ans=0;
      char str='0';
      for(ll i=s.size()-1;i>0;i--)
      {
         if(s[i]==s[i-1])
         {
            x=sum[s[i]-'a'][pos]-sum[s[i]-'a'][i];
            ans+=(pos-i)-x;
            if(str!='0' && s[i]!=str)
               ans+=(s.size()-1-pos);
            str=s[i];
            for(ll j=i-1;j>=0;j--)
            {
               if(s[j]==s[j+1])
                  i--;
               else
                  break;
            }
            pos=i-1;
         }
      }
      cout<<ans<<endl;
   }
   return 0;
}
