using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{

			string s = Console.ReadLine();

			int ans = 0;
			while (true) {
				bool f = false;
				for (int i = 1; i < s.Length - 2; i++) {
					if (s[i] != s[i + 1] && s[i - 1] != s[i + 2]) {
						s = s.Substring(0, i) + s.Substring(i + 2, s.Length - (i + 2));
						ans += 2;
						f = true;
						break;
					}
				}
				if (!f) {
					for (int i = 0; i < s.Length - 1; i++) {
						string s1 = "", s2 = "";
						if (s[i] != s[i + 1]) {
							s1 = s.Substring(0, i);
							if (i + 2 < s.Length) {
								s2 = s.Substring(i + 2, s.Length - (i + 2));
							}
							s = s1 + s2;
							ans += 2;
							f = true;
							break;
						}
					}
				}
				if (!f) {
					break;
				}
			}
			Console.WriteLine(ans);

		}
	}
}