#include <bits/stdc++.h>

using namespace std;

bitset<26> used;
string t = "";

bool ok(int pos) {
    if (pos == 0) {
        used[t[0] - 'a'] = 1;
        return true;
    }
    if (t[pos] == t[pos - 1]) return true; 
    if (used[t[pos] - 'a']) return false;
    used[t[pos] - 'a'] = 1;
    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++) {
        t = "";
        used.reset();
        for (int j = i; j < n; j++) {
            t += s[j];
            if (ok(j - i)) ans.insert(t);
           	else break;
        } 
    } 
    out << ans.size() << endl;
    return 0;
}
