using System;
using System.Collections;
using System.Collections.Generic;

class g
{
    static public int r;
    static public string s;
}

class HelloWorld
{
    static void pok(int l,int d,int br)
    {
        int k = 0;
        while (d+(d-l+1) < g.s.Length)
        {
            k = 0;
            for (int i = 0; i <=d-l ; i++)
            {
                if (g.s[d - i] == g.s[d + i + 1]) k++;
            }
            if (k != 0) pok(d + 1, d + 2,br+k);                            
            d++;
        }
            if (g.r < br) g.r = br;
    }

    static void Main()
    {
        g.r = 0;
        g.s=Console.ReadLine();
        pok(0, 2, 0);
        Console.WriteLine(g.r);
    }
}