#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
#define TO_STRING(VariableName) # VariableName
#define debug(x) cerr<<TO_STRING(x)<<" : "<<x<<" "<<endl;
void debugs() { cerr << endl; }
template <class T, class... Args>
void debugs(const T& x, const Args &... args) {
		cerr << x << " ";
		debugs(args...);
}
template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>& p) {
		ost << "{ " << p.first << ", " << p.second << " }";
	return ost;
}
template<class T>
ostream& operator<<(ostream& ost, const vector<T>& v) {
	ost << "{ ";
	for (int i = 0; i < v.size(); i++) {
		if (i)ost << ", ";
		ost << v[i];
	}
	ost << " }";
	return ost;
}
template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>& v) {
	ost << "{ ";
	for (auto p : v) {
		ost << "{ " << p.first << ", " << p.second << " }";
	}
	ost << " }";
	return ost;
}
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = 0;
//---------------------------------//

int main() {
	string s;
	cin >> s;
	vector<ll> cnt(26);
	char p_c = s.back();
	cnt[p_c-'a']++;
	ll ans = 0;
	for (ll i = s.length()-2; i >= 0; i--){
		char c = s[i];
		cnt[c-'a']++;
		if (p_c == c){
			ans+=(s.length()-i) - cnt[c-'a'];
			rep(j, 26) cnt[j] = 0;
			cnt[c-'a'] = s.length()-i;
		}
		p_c = c;
	}
	cout << ans << endl;
	return 0;
}

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> PII;
#define PB push_back
#define fi first
#define se second
#define MP make_pair
const int P = 1000000007;
const int V = 200100;
char s[V];
int a[30];
int main() {
    while (~scanf("%s", s)) {
        int n = strlen(s);
        memset(a, 0, sizeof(a));
        int last = -1;
        LL ans = 0;
        for (int i = n - 1; i >= 0; --i) {
            a[s[i] - 'a']++;
            if (i != n - 1 && s[i + 1] == s[i]) {
                if (last == -1) {
                    ans += n - i - a[s[i] -'a'];
                } else if (s[last] == s[i]) {
                    ans += last - i - a[s[i] - 'a'];
                } else {
                    ans += n - i - a[s[i] - 'a'];
                }
                last = i;
                for (int j = 0; j < 26; ++j) a[j] = 0;
            }
        }
        printf("%lld\n", ans);
    }
    return 0;
}

/*
accept
atcoder
anerroroccurred
*/
