// #pragma GCC optimize("O2")
#include <bits/stdc++.h>
// #include "D:/program_learning/vs_code/workplace/ACMtemplate/data_struct/UnionFindSet.hpp"
using namespace std;

#define mp make_pair
#define phb push_back
#define ppb pop_back
#define eb emplace_back
#define pp pop
#define ph push
#define ff first
#define ss second
#define htl(v, n) (v)+1,(v)+1+(n), greater<decltype((v)[1])>()
#define lth(v, n) (v)+1,(v)+1+(n), less<decltype((v)[1])>()
#define Max(a, b) (((a) > (b)) ? (a) : (b))
#define Min(a, b) (((a) < (b)) ? (a) : (b))
#define isZero(x) ((x)>0?(x):-(x)<eps)
#define isEqual(x, y) (abs((x)-(y))<eps)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define iFOR(it, begin, end) for(auto it = (begin); it!=(end);it++)
#define rFOR(i, a, b) for(int i = (a); i >= (b); i--)
#define vFOR(it, a) for(auto it = a.begin();it != a.end();it++)
#define aFOR(a, s) for(auto & (a) : (s))
#define pFOR(i, j, l, r, sit) for(int i = l,j = r; sit ;i++, j--)
#define DEBUG(x) cout << #x << " = " << (x) << endl
#define checktime() cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" ; system("pause")
#define endl '\n'
#define faster_cpp_io() std::ios::sync_with_stdio(false),std::cin.tie(0),std::cout.tie(0)
#define setp(n) fixed << setprecision(n)
#define cases(t,i) int t;cin >> t;for(int i = 1;i<=t;i++)

using pll = pair<long long,long long>;
using pii = pair<int,int>;
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using vs = vector<string>;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using mll = map<long long, long long>;
using umll = unordered_map<long long, long long>;

constexpr ll mod = 10007;
constexpr ll inf = 0x7f7f7f7f7f7f7f7f;
constexpr ld eps = 1e-9;
constexpr ll cap = 1e5+5;
constexpr ld pi = acos(-1);

string in;ll ans;
ll dic[26];

void solve(){
    cin >> in;
    ll len = in.size();
    rFOR(i, len - 1, 0){
        if(i >= len - 2){
            dic[in[i] - 'a'] ++;
        }
        else{
            if(in[i] == in[i + 1] && in[i] != in[i + 2]){
                ans += (len - i - 1 - dic[in[i] - 'a']);
                FOR(j, 0, 25){
                    if(in[i] - 'a' == j){
                        dic[in[i] - 'a'] = len - i;
                    }else{
                        dic[j] = 0;
                    }
                }
            }
            else
                dic[in[i] - 'a'] ++ ;
        }
    }
    cout << ans << endl;
}

int main()
{
	faster_cpp_io();

    // cases(t,i)
    solve();

    // checktime();
    return 0;
}
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) (v).begin(), (v).end()
using ll = long long;
constexpr int INF = 1e9;
constexpr long long LINF = 1e18;
constexpr long long MOD = 1e9 + 7;

signed main() {
    string s;
    cin >> s;
    int n = s.size();
    reverse(ALL(s));
    ll ans = 0;
    ll cnt[26] = {};
    char pre = '(';
    rep(i, n) {
        if (pre == s[i]) {
            rep(j, 26) {
                if (j == s[i] - 'a') continue;
                ans += cnt[j];
                cnt[s[i] - 'a'] += cnt[j];
                cnt[j] = 0;
            }
        }
        cnt[s[i] - 'a']++;
        pre = s[i];
    }
    cout << ans << endl;
    return 0;
}