#include <bits/stdc++.h>
int main(void) {
  char s[100002];
  int i, j, count = 0;
  for (i = 0; i < 100002; i++) {
    s[i] = '\0';
  }
  scanf("%s", s);
  i = 0;
  for (;;) {
    if (s[i + 2] == '\0') break;
    if (s[i] != s[i + 1]) {
      j = 0;
      for (;;) {
        if (s[i + j + 2] == '\0') {
          s[i + j] = '\0';
          s[i + j + 1] = '\0';
          count += 2;
          i = -1;
          break;
        }
        s[i + j] = s[i + j + 2];
        j++;
      }
    }
    i++;
  }
  printf("%d\n", count);
  return 0;
}
