#include<iostream>
#include<string>
#include<math.h>
#include<vector>
using namespace std;
using ll= long long;
int main() {
	string S;
	cin >> S;
	int count=0;
	int k = 0;
	while (S[k]) {
		count++;
		k++;
	}
	
	int henka=0;
	int kai=0;
	int tmp = count;
	for (int j = 0; j < tmp; j++) {
		henka = 0;
		for (int i = 0; i < count - 1; i++) {
			if (S[i] != S[i + 1]&&S[i]!=2&&S[i+1]!=2) {
				
				for (int l = 0; i + 2 + l < count; l++) {
					S[i + l] = S[i + 2 + l];
					
				}
				S[count-1]=2;
				S[count-2]=2
				count -= 2;

				kai += 2;
				i++;
				henka = 1;
			}
		
		}



		if (henka == 0) {
			break;
		}
	}
		cout << kai;

}
