#include <iostream>
#include <unordered_map>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

int max(int a, int b) {
    return (a > b) ? a : b;
}

int odds(std::string pal) {
    std::unordered_map<char, int> a;
    int res = 0;
    for (int i = 0; i < pal.length(); i++) {
        if (a[pal[i]] % 2 == 0) {
            res++;
        }
        else {
            res--;
        }
        a[pal[i]]++;
    }
    return res;
}

int evalScore(std::vector<std::string> r) {
    std::unordered_map<int, std::unordered_map<int, char>> score;
    int index1 = 0;
    for (int i = 0; i < r.size(); i++) {
        std::string str = r[i];
        int coef = 1;
        if (i % 2 == 1) {
            coef = -1;
        }
        for (int j = 0; j < str.length(); j++) {
                //std::cout << i << " " << index1 << " " <<  str[i] << std::endl;
            score[i][index1] = str[j];
            index1 += coef;
        }
        index1 -= coef;

    }
    int res = 0;
    int it = 0;
    for (auto i = score.begin(); i != score.end(); i++) {
        int level = i->first;
        if (level == r.size()-1) continue;
        auto score1 = i->second;
        for (auto j = score1.begin(); j != score1.end(); j++) {
            //std::cout << level << " " << j->first << " " << score[level][j->first] << " " << score[level + 1][j->first] << std::endl;
            if (j->second == score[level + 1][j->first] && score[level + 1][j->first] != 0) {
                res++;
            }
        }
        it++;
    }
    return res;
}

std::vector<std::string> ress;
std::unordered_map<std::string, int> memory;

int eval(std::string a, std::vector<std::string> res) {
    int max = 0;
    for (int i = 0; i < a.length(); i++) {
        int k = i + 1;
        while (/*k <= i + (a.length()) / 2 + 1 && */ k < a.length()) {
            if (a[k] == a[i]) {
                std::string a1 = a.substr(0, i + (k - i-1) / 2 + 1), a2 = a.substr(i + (k - i-1) / 2 + 1, a.length() - (k - i) / 2 - 1);
                auto res2(res);
                res2.push_back(a1);
                int nM = eval(a2, res2);
                if (nM > max) {
                    max = nM;
                }
            }
            k += 2;
        }
        if (/*k >(a.length() + i) / 2 + 1 || */k >= a.length()) {
            continue;
        }

    }
    if (max == 0) {
        res.push_back(a);
        int r = evalScore(res);
        return r;
    }
    return max;
}

int main()
{
    std::string a;
    std::cin >> a;
    std::cout << eval(a, {}) << std::endl;
}