#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Cube = struct {
  int c;
  bool is_removed;
};
Cube cubes[1000000];
int solve(int n, int remove_num) {
  int ini_remove_num = remove_num;
  int prev_c;
  int prev_c_index;
  bool prev_c_init_flag = false;
  for (int i = 0; i < (int)(n); i++) {
    if (!cubes[i].is_removed) {
      if (!prev_c_init_flag) {
        prev_c = cubes[i].c;
        prev_c_index = i;
        prev_c_init_flag = true;
      } else {
        if (cubes[i].c != prev_c) {
          cubes[i].is_removed = true;
          cubes[prev_c_index].is_removed = true;
          prev_c_init_flag = false;
          remove_num += 2;
        } else {
          prev_c = cubes[i].c;
          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);
  string S;
  std::cin >> S;
  for (int i = 0; i < (int)(S.size()); i++) {
    cubes[i] = {stoi(S.substr(i, 1)), false};
  }
  std::cout << solve(S.size(), 0) << std::endl;
  return 0;
}
