#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  S.insert(0, "2");
  int X = S.size(), i = 1;
  while (i != S.size() - 1) {
    if ((S[i] != 2) && (S[i] != S[i + 1])) {
      S.erase(i, 2);
      if (S.size() == 1) break;
      if (i > 2) i--;
    } else
      i++;
  }
  cout << X - S.size() << endl;
}
