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

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

int sums[MAX + 1];

bool good(int L, int R) {
    return sums[R - 1] - sums[L] < 2;
}

struct Substring {
    int L, R;

    Substring(int _L, int _R) : L(_L), R(_R) {}

    bool operator < (const Substring& that) const {
        for (int i = L, j = that.L; i < R && j < that.R; i++, j++) {
            if (s[i] < s[j]) {
                return true;
            }
            if (s[i] > s[j]) {
                return false;
            }
        }
        if (R - L < that.R - that.L) {
            return true;
        }
        return false;
    }
};

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

    scanf("%s", s);
    int n = strlen(s);
    sums[0] = 0;
    for (int i = 1; i < n; i++) {
        sums[i] = sums[i - 1] + (s[i] != s[i - 1]);
    }

    set<Substring> was;

    for (int L = 0; L < n; L++) {
        for (int R = L + 1; R <= n; R++) {
            if (good(L, R)) {
                was.insert({L, R});
            }
        }
    }

    printf("%d\n", was.size());
}
