using System;
using System.Collections.Generic;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            string niska = Console.ReadLine();
            Dictionary<char, int> baza = new Dictionary<char, int>();

            for (int i = 0; i < niska.Length; i++)
            {
                int brojac = 0;
                char slovo = niska[i];
                if (!baza.ContainsKey(slovo))
                {
                    baza.Add(slovo, 0);
                }

                for (int j = i; j < niska.Length; j++)
                {
                    if (niska[j] == niska[i] && i != j)
                    {
                        if ((j - i - 1) % 2 == 0)
                        {
                            brojac++;
                            baza[slovo] += brojac;
                            break;
                        }
                    }
                }
            }

            int max = 0;
            foreach (char i in niska)
            {
                if (max < baza[i])
                    max = baza[i];
            }
            if (max > 0)
                Console.WriteLine(max - 1);
            else Console.WriteLine(max);
        }
    }
}