#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef pair<int,lld> pil;
typedef pair<lld,int> pli;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

const int MAX = 202020;
int dp[26];
void solve(int tc){
	string s;
	cin >> s;
	lld ans = 0;
	char rr = '?';
	for(int e=sz(s)-1;e>=0;e--){
		if(s[e]==s[e+1]&&e+1<sz(s)){
			ans += sz(s) - 1 - e - dp[s[e]-'a'];
			memset(dp,0,sizeof(dp));
			dp[s[e]-'a'] = sz(s) - e;
		}else{
			dp[s[e]-'a']++;
		}
	}
	printf("%lld\n",ans);
}


int main(void){
	/*
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	*/
	int tc = 1;
	/*
		cin >> tc;
	*/
	for(int test_number=1;test_number<=tc;test_number++){
		solve(test_number);
	}
	return 0;
}
#include <bits/stdc++.h>
using namespace std;
int main(){
   /* long double n;
    cin>>n;
    long long unsigned t = n;
    cout<<t; 
     stringstream ss;  
       ss<<n;  
        string s;  
         ss>>s;
         long long a = (s.size());
         long long x = 0;
         while(x<a){
             if(s[x]=='.'){
                 break;
             }
            cout<<s[x];
             x++;
         } 
         //cout<<s;*/
         string s;
         cin>>s;
                  long long a = (s.size());
         long long x = 0;
         while(x<a){
             if(s[x]=='.'){
                 break;
             }
            cout<<s[x];
             x++;
         } 
         
}