using System;
using System.Collections;

class Problem
{
    static void Main()
    {
        string s = Console.ReadLine();
        ArrayList al = new ArrayList();
        int j = 0,i;

        for (i = 0; i < s.Length; i++)
        {
            al.Add(Convert.ToInt32(s[i]));
        }
        for (i = 0; i < s.Length-1; i+=j)
        {
            if (i + 1 > al.Count-1) { break; }
            if ((int)al[i] + (int)al[i + 1]==97)
            {
                if (i != 0) { j = -1; } else { j = 0; }
                //Console.WriteLine("{0},{1}", al[i], al[i + 1]);
                al.RemoveRange(i, 2);
            }
            else
            {
                //Console.WriteLine("あ{0},{1}", al[i], al[i + 1]);
                j = 1;
            }
        }
        Console.WriteLine(s.Length-al.Count);
    }
}