#include <bits/stdc++.h>
using namespace std;
using ll = long long;
string S;
bool is_removed[1000000];
int solve(int n, int remove_num) {
  int ini_remove_num = remove_num;
  char prev_c;
  int prev_c_index;
  bool prev_c_init_flag = false;
  for (int i = 0; i < (int)(n); i++) {
    if (!is_removed[i]) {
      if (!prev_c_init_flag) {
        prev_c = S[i];
        prev_c_index = i;
        prev_c_init_flag = true;
      } else {
        if (S[i] != prev_c) {
          is_removed[i] = true;
          is_removed[prev_c_index] = true;
          prev_c_init_flag = false;
          remove_num += 2;
        } else {
          prev_c = is_removed[i];
          prev_c_index = i;
        }
      }
    }
  }
  return (ini_remove_num == remove_num) ? remove_num : solve(n, remove_num);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cin >> S;
  for (int i = 0; i < (int)(S.size()); i++) {
    is_removed[i] = false;
  }
  std::cout << solve(S.size(), 0) << std::endl;
  return 0;
}
