#include <bits/stdc++.h>
using namespace std;
struct node {
  char element;
  struct node *next;
};
struct node *initlist() {
  struct node *n;
  n = (struct node *)malloc(sizeof(struct node));
  n->next = NULL;
  return n;
}
void insert(struct node *p, char x) {
  struct node *n;
  n = (struct node *)malloc(sizeof(struct node));
  n->element = x;
  n->next = p->next;
  p->next = n;
}
void deletex(struct node *p) {
  if (p->next != NULL) {
    p->next = p->next->next;
  }
}
int main() {
  string S;
  cin >> S;
  size_t len = S.length();
  struct node *list = initlist();
  struct node *itr = list, *pre;
  for (int i = 0; i < len; i++) {
    insert(list, S[i]);
  }
  int ans = 0, count = 0;
  pre = itr;
  while (1) {
    if (itr == NULL || itr->next == NULL || itr->next->next == NULL) break;
    if (itr->next->element != itr->next->next->element) {
      deletex(itr);
      deletex(itr);
      ans += 2;
      itr = pre;
    } else {
      pre = itr;
      itr = itr->next;
    }
  }
  cout << ans << endl;
  return 0;
}
