#include <bits/stdc++.h>
using namespace std;
int main(void) {
  long long N;
  string S;
  cin >> S;
  N = S.size();
  string cur_S = S;
  string new_S;
  bool update = true;
  long long counter = 0;
  if (cur_S.size() < 2) {
    cout << 0 << endl;
    return 0;
  }
  while (update) {
    update = false;
    N = cur_S.size();
    char first_w = cur_S[0];
    new_S = first_w;
    for (int i = 1; i < N; i++) {
      if (first_w != cur_S[i]) {
        counter += 2;
        if (cur_S.size() > 2) {
          for (int j = 0; j < new_S.size() - 2; j++) new_S[j] = new_S[j];
          update = true;
        } else {
          update = false;
        }
      } else {
        new_S = new_S + cur_S[i];
      }
    }
    cur_S = new_S;
  }
  cout << counter << endl;
  return 0;
}
