/*
Author: Zcus
Blog: https://cnblogs.com/zcus
*/

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mp make_pair
#define debug(x) cout << #x << " = " << x << endl
#define For(i, x, y) for (int i = x; i <= y; i++) 
#define Rep(i, x, y) for (int i = x; i >= y; i--) 
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)
#define filein(FILE_NAME) freopen(FILE_NAME".in", "r", stdin);
#define fileout(FILE_NAME) freopen(FILE_NAME".out", "w", stdout);

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define I int
inline I ri() {
	I s = 0, w = 1;
	char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') w = -1; c = getchar();}
	while (c >= '0' && c <= '9') { s = (s << 1) + (s << 3) + (c ^ 48); c = getchar();}
	return s * w;
}
#undef I

#define int long long

const int maxn = 2e5 + 540;

char s[maxn];
int n;


int lascor, las = 0;


int Sum[maxn][28];
signed main() {
	//file("3");
	scanf("%s", s + 1); n = strlen(s + 1);

	int ans = 0;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= 26; j++) Sum[i][j] = Sum[i - 1][j];
		Sum[i][s[i] - 'a' + 1]++;
	}
	las = n + 1;
	for (int i = n - 2; i >= 1; i--) {
		if (s[i] == s[i + 1]) {
			if (lascor != s[i]) {
				ans = ans + n - (i + 1);
				if (las && las - 1 >= i + 1) ans = ans - (Sum[las - 1][s[i] - 'a' + 1] - Sum[i + 1][s[i] - 'a' + 1]);
			}
			else if (las - 1 >= i + 1) ans = ans + max(0ll, (las - 1 - (i + 2) + 1) - (Sum[las - 1][s[i] - 'a' + 1] - Sum[i + 1][s[i] - 'a' + 1]));
			lascor = s[i]; las = i;
		}
	}
	
	cout << ans << endl;
	return 0;
}

#include <bits/stdc++.h>
using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long int
#define sd(x) scanf("%lld",&x)
#define sdi(x) scanf("%d",&x)
#define sdc(c) scanf("%c",&c)
#define inf 1000000000000000000ll
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define bits(x) __builtin_popcountll(x)
#define ld long double
#define test() ll test; cin>>test; while(test--)
#define fi first
#define se second
#define all(x) x.begin(),x.end()

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

clock_t time_p = clock();
void time_taken()
{
    time_p = clock() - time_p;
    cerr << "Time Taken : " << (float)(time_p) / CLOCKS_PER_SEC << "\n";
}

inline ll GCD(ll x, ll y) {
    if(x<y) swap(x,y);
    if(x==0) return y;
    if(y==0) return x;
    return GCD(x%y,y);
}

ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}

ll power(ll x, ll n, ll mod) {
    ll res = 1;
    x %= mod;
    while(n) {
        if(n&1) {
            res = ((res*x)%mod+mod)%mod;
        }
        x = ((x*x)%mod+mod)%mod;
        n>>=1;
    }

    return res;
}

const int MOD = 1e9+7;

inline ll add(ll x, ll y, ll MOD) {
    x %= MOD;
    y %= MOD;
    ll ans = (x+y)%MOD;
    return ans;
}

inline ll mul(ll x,ll y, ll MOD) {
    x %= MOD;
    y %= MOD;
    ll ans = ((x*y)%MOD+MOD)%MOD;
    return ans;
}

int main() {
    fastio;
    string s;
    cin>>s;

    int n = s.length();
    vector<int> v(n);

    for(int i=0;i<n;i++) {
        v[i] = s[i]-'a';
    }

    vector<int> cnt(27,0);
    ll res = 0;
    cnt[v.back()]++;
    for(int i=n-2;i>=0;i--) {
        if(v[i]==v[i+1]) {
            for(int j=0;j<26;j++) {
                if(v[i]!=j) {
                    res += cnt[j];
                    cnt[v[i]] += cnt[j];
                    cnt[j] = 0;
                }
            }
        }
        cnt[v[i]]++;
    }

    cout<<res<<endl;
    
    time_taken();
}
