#include <string>
#include <iostream>

void Untie();
int SnakeScore(const std::string&);

int main() {
    Untie();
    std::string text;
    std::cin >> text;
    std::cout << SnakeScore(text) << std::endl;
    return 0;
}

void Untie() {
    std::ios_base::sync_with_stdio(false);
    std::cout.tie(nullptr);
    std::cerr.tie(nullptr);
    std::cin.tie(nullptr);
}
int SnakeScore(const std::string& text) {
    int* distances = new int[text.size() / 2];
    int score = 0;
    bool neighbouring = true;
    for (int i = 0; i < text.size() / 2; i++) {
        distances[i] = 0;
    }
    for (int i = 0; i < text.size() - 1; i++) {
        for (int j = 1 + 2 * neighbouring; j < text.size() - i; j += 2) {
            if (text.at(i) == text.at(i + j)) {
                distances[j / 2]++;
                neighbouring = (j == 1);
                break;
            }
            neighbouring = false;
        }
    }
    int d = 0;
    for (int i = 0; i < 2; i++) {
        while (!distances[d] && d < text.size() / 2) {
            d++;
        }
        if (d < text.size() / 2) {
            score += distances[d++];
        }
    }
    delete[] distances;
    return score;
}