#include <bits/stdc++.h>
int main() {
  std::string S;
  std::cin >> S;
  int c = 0;
  std::vector<char> B(S.length());
  int ans = 0;
  for (int i = 0; i < S.length() - 1; i++) {
    if (S[i] != S[i + 1]) {
      i++;
      ans++;
      continue;
    }
    if (c == 0 || B[c - 1] == S[i]) {
      B[c++] = S[i];
    } else {
      c--;
      ans++;
    }
  }
  std::cout << (ans * 2) << std::endl;
  return 0;
}
