#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string S;
  cin >> S;
  int N = S.size();
  int first = 0, second = 1;
  int ans = 0;
  while (second < N) {
    if (S[first] != S[second]) {
      ans += 2;
      S[first] = S[second] = 'x';
      while (first >= 0 && S[first] == 'x') first--;
      if (first < 0) {
        first = second + 1;
        second = first + 1;
      } else
        second++;
    } else {
      first = second;
      second++;
    }
  }
  cout << ans << endl;
  return 0;
}
