using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.SymbolStore;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Net.WebSockets;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.WindowsRuntime;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Schema;
using System.Numerics;
//using System.Data;
//using System.Drawing;

namespace ConsoleApplication2
{
    class Program
    {
        struct Par
        {
            public int cena;
            public int br;     
        }
        static int lastocceq(string s, int i1, int i2)
        {
            if(i2>=s.Length)
            {
                int raz = i2-s.Length+1;
                i1 += raz;
                i2 = s.Length - 1;
            }
            while(i1<i2)
            {
                if (s[i1] == s[i2])
                    return i2;
                i1++;
                i2--;
            }
            return 0;
        }
  
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            int n = s.Length;
            int vel = n / 2;
            Par[,] dp = new Par[vel + 1, n + 1];
            int max = 0;
            for(int i=1;i<=n;i++)
            {
                dp[1, i].br = i;
            }
            for(int i=2;i<=vel;i++)
            {
                int ll = 0;
                for (int j = 1 + (i - 1) * 2; j <= n; j++)
                {
                    if (j > ll+1)
                        ll = 0;
                    dp[i, j].br = dp[i, j - 1].br + 1;
                    dp[i, j].cena = dp[i, j - 1].cena;
                    if (j - dp[i, j].br * 2 >= 0)
                        if (s[j - dp[i, j].br * 2] == s[j - 1])
                            dp[i, j].cena++;
                    if (ll == 0)
                        if (dp[i - 1, j - 1].br >= 2)
                        {
                            ll = lastocceq(s, j - dp[i - 1, j - 1].br - 1, j-2 + dp[i - 1, j - 1].br);
                            int vr = dp[i - 1, j - 1].cena;
                            if (j >= 2)
                                if (s[j - 2] == s[j - 1])
                                    vr++;
                            if (vr >= dp[i, j].cena && ll != 0)
                            {
                                dp[i, j].cena = vr;
                                dp[i, j].br = 1;
                            }
                            else ll = 0;
                        }
                }
                
                max = Math.Max(dp[i, n].cena,max);
            }
            Console.WriteLine(max);

            /*
            dp[i, j].br = dp[i, j - 1].br + 1;
            dp[i, j].cena = dp[i, j - 1].cena;
            if (j - dp[i, j].br * 2 >= 0)
                if (s[j - dp[i, j].br * 2] == s[j - 1])
                    dp[i, j].cena++;
            if (dp[i - 1, j - 1].br >= 2)
            {
                int vr = dp[i - 1, j - 1].cena;
                if (j >= 2)
                    if (s[j - 2] == s[j - 1])
                        vr++;
                if (vr >= dp[i, j].cena)
                {
                    dp[i, j].cena = vr;
                    dp[i, j].br = 1;
                }
            }*/
        }
    }
}