#include <bits/stdc++.h>

using namespace std;

bool ok(string s) {
    bitset<26> used;
    used.set(s[0] - 'a');
    int n = s.length();
    for (int i = 1; i < s.length(); i++) {
        if (s[i] == s[i - 1]) continue;
        if (used[s[i] - 'a']) return false;
        used.set(s[i] - 'a');
    } 
    return used.count() < 3;
}

int main() {
    ifstream in("strange.in");
    ofstream out("strange.out");
    string s;
    in >> s;
    int n = s.length();
    unordered_set<string> ans;
    for (int i = 0; i < n; i++) {
        string t = "";
        for (int j = i; j < n; j++) {
            t += s[j];
            if (ok(t)) ans.insert(t);
            else break;
        } 
    } 
    out << ans.size() << endl;
    return 0;
}
