S = input()


N = len(S)
ind = N-1
last = S[ind]
flag = True
ans = 0
rev_rem = False
rev_rev_rem = False

while ind > 0:

	if last == S[ind-1]:
		ans += 2
		ind -= 1
		if ind-2 >= 0 and S[ind-2] != S[ind-1]:
			rev_rev_rem = rev_rem
			rev_rem = False
	elif (not rev_rem) and rev_rev_rem and last != S[ind-1]:
		ans += 2
		rev_rev_rem = False
	else:
		rev_rev_rem = rev_rem
		rev_rem = True
	ind -= 1
	last = S[ind]

print(ans)