#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int ans = 0;
  while (true) {
    vector<int> E;
    int i = 0;
    while (i < S.size()) {
      if (S[i] == S[i + 1]) {
        E.push_back(i);
        i += 2;
      } else {
        i++;
      }
    }
    if (E.size() == 0) {
      break;
    }
    ans += 2 * E.size();
    int f = 0;
    for (int j = 0; j < E.size(); j++) {
      S.erase(S.begin() + E.at(j) - f, S.begin() + E.at(j) + 2 - f);
      f += 2;
    }
  }
  cout << ans << endl;
  return 0;
}
