#include<bits/stdc++.h>
 
using namespace std;

int main(){
  
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    string s;

    cin >> s;

    int n = s.size();
    vector<pair<int, int>> a(n);

    a[n-1].first = 0, a[n-2].first = 0, a[n-1].second = 1, a[n-2].second = 2;

    for(int i = n-3; i >= 0; --i){
        int maxCnt = 0, lvlLen = a[i+1].second+1;
        for(int j = 2; i+j < n-1; ++j){
            int cnt = a[i+j].first;
            string tmp1 = s.substr(i, j), tmp2 = s.substr(i+j, a[i+j].second);
            int p1 = tmp1.size()-1, p2 = 0;
            while(p1 >= 0 && p2 < tmp2.size()){
                if(tmp1[p1--] == tmp2[p2++]) ++cnt;
            }

            if(cnt > maxCnt){
                maxCnt = cnt;
                lvlLen = j;
            }
        }
        a[i].first = maxCnt, a[i].second = lvlLen;
    }

    int max = 0;

    for(int i = 0; i < n; ++i){
        if(a[i].first > max) max = a[i].first;
    }
    
    cout << max << '\n';
    return 0;
}