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

const int N = 233333;
const int mod = 10;
const int phi = 4;

int cnt[26];
char s[N];

int main() {
    scanf("%s", s + 1);
    int n = strlen(s + 1);
    ll ans = 0;
    for(int i = n; i >= 1; --i) {
        cnt[(s[i]-'a')]++;
        if(i < n && s[i] == s[i+1]) {
            int len = n - i + 1;
            ans += (len - cnt[s[i]-'a']);
            cnt[s[i]-'a'] = len;
            for(int j = 0; j < 26; ++j) {
                if(j == (s[i]-'a')) continue;
                else cnt[j] = 0;
            }
        }
    }
    printf("%lld\n", ans);
}
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define rng(a) a.begin(), a.end()
#define ina(n,a) cin >> n; for(int i = 1; i <= n; i++) cin >> a[i]
#define sz(x) (int)(x).size()
#define se second
#define fi first
#define prev            coyhhhhhhyoc    
#define next          sdNNNmNNNNNNNmds  
#define y0           hNNNNy_yNNNNNN_sNh
#define y1          mNNNNNdtdNNNNNNtsNNm
#define yn          mNNNNNNNNy___smNNNms
#define tm            oooooosyysooooot 
#define read               tyhyt        
#define rank              ytmNmo         
#define index              yyy
#define pb push_back
#define pcnt __builtin_popcountll
#define rrep(i,a,b) for(int i = (b); i >= (a); i--)
#define rall(x,a) for(auto x : a)
#define MOD 1000000007
#define endl "\n"
#define int long long
typedef long long ll;
using namespace std;

const int N = 222222;
int cnt[26];
string s;
int n;

int solve() {
    cin >> s;
    n = sz(s);
    int ans = 0;
    rrep(i, 1, n) {
        int c = s[i - 1] - 'a';
        if(i < n && s[i] == c + 'a') {
            ans += n - i - cnt[c];
            fill(cnt, cnt + 26, 0);
            cnt[c] = n - i + 1;
        } else {
            cnt[c]++;
        }
    }
    cout << ans << endl;
    return 0;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int t = 1;
    while(t--) {
        solve();
    }
    return 0;
}
