using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder_C
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[] s = Console.ReadLine().Select(x => x == '1').ToArray();

            var o = Get1(s, new List<int>()).Max(x => x.Count());
            Console.WriteLine(o);
        }

        public static IEnumerable<IEnumerable<int>> Get1(bool[] s, List<int> d)
        {
            foreach (var ij in Get2(s, d))
            {
                var nd = d.ToList();
                nd.Add(ij[0]);
                nd.Add(ij[1]);
                yield return Get1(s, nd)
                    .OrderByDescending(x => x.Count())
                    .First();
            }
            yield return d;
        }

        public static IEnumerable<int[]> Get2(bool[] s, IEnumerable<int> d)
        {
            for (int i = 0; i < s.Length - 1; i++)
            {
                if (d.Contains(i))
                {
                    continue;
                }

                int j = Enumerable
                    .Range(i + 1, s.Length - i - 1)
                    .FirstOrDefault(x => !d.Contains(x));

                if (j != 0 && s[i] != s[j])
                {
                    yield return new[] { i, j };
                }
            }
        }
    }
}
