#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
inline long long int max(long long int a, long long int b) {
  if (a < b)
    return b;
  else
    return a;
}
int main() {
  int i, k, l;
  string S;
  string Out;
  int N;
  cin >> S;
  bool flg = true;
  int ret = 0;
  int End = S.size() - 1;
  while (flg) {
    flg = false;
    for (i = 0; i < S.size() - 1; i++) {
      if (S[i] != S[i + 1]) {
        ret += 2;
        flg = true;
        i++;
      } else {
        Out.push_back(S[i]);
      }
    }
    if (i == S.size() - 1) {
      Out.push_back(S[i]);
    }
    S = Out;
    Out = "";
  }
  cout << dec << ret;
  return 0;
}
