#include <cstdio>
#include <cstring>
#include <string>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define prev gotohell

const int MAX = 200001;
char s[MAX];

vector<int> singles(26);
set<pair<int, int>> pairs[26][26];
int cur, prev;
char curc, prevc;

void relax() {
    if (curc != -1) {
        singles[curc - 'a'] = max(singles[curc - 'a'], cur);
    }

    if (prevc != -1) {
        for (int i = 1; i <= prev; i++) {
            for (int j = 1; j <= cur; j++) {
                pairs[prevc - 'a'][curc - 'a'].insert({i, j});
            }
        }
    }
}

int main() {
    freopen("strange.in", "r", stdin);
    freopen("strange.out", "w", stdout);

    scanf("%s", s);
    int n = strlen(s);

    curc = prevc = -1;
    for (int i = 0; i < n; i++) {
        if (s[i] == curc) {
            cur++;
        } else {
            relax();

            prevc = curc;
            prev = cur;
            cur = 1;
            curc = s[i];
        }
    }
    relax();

    int ans = accumulate(singles.begin(), singles.end(), 0);
    for (int i = 0; i < 26; i++) {
        for (int j = 0; j < 26; j++) {
            ans += pairs[i][j].size();
        }
    }
    printf("%d\n", ans);
}
