#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
int main() {
  string S;
  cin >> S;
  int n = S.size();
  queue<int> q, qq, q2, qclear;
  for (int i = 0; i < n; i++) {
    q.push(i);
  }
  int a, b;
  int counter = 0;
  while (q.size()) {
    qq = q;
    int qsize = q.size();
    for (int i = 0; i < qsize - 1; i++) {
      if (i == 0) {
        a = q.front();
        q.pop();
      }
      b = q.front();
      q.pop();
      if (S.at(a) == S.at(b)) {
        q2.push(a);
        a = b;
      } else
        counter += 2;
    }
    if (qq == q2) break;
    q = q2;
    q2 = qclear;
  }
  cout << counter << endl;
}
