#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int c = 0;
  bool f = true;
  while (f) {
    int len = S.length();
    string w = "";
    f = false;
    for (int i = 0; i < len - 1; i++) {
      if (S[i] != S[i + 1]) {
        f = true;
        c++;
        i++;
      } else {
        w = w + S[i];
      }
    }
    if (S[len - 2] == S[len - 1]) w = w + S[len - 1];
    S = w;
  }
  cout << 2 * c << endl;
}
