#include <bits/stdc++.h>
std::string removeCube(std::string c);
int main() {
  std::string s;
  std::cin >> s;
  std::cout << s.size() - removeCube(s).size();
  return 0;
}
std::string removeCube(std::string c) {
  if (c.empty()) return c;
  for (int i = 0; i < c.size() - 1; ++i) {
    if (c[i] != c[i + 1]) {
      c = c.erase(i, 2);
      return removeCube(c);
    }
  }
  return c;
}
