#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
char s[N];
int len, lft[N], rig[N], exi[N], ans;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
int main() {
  scanf("%s", s);
  len = strlen(s);
  for (int i = 0; i < len; ++i) {
    exi[i] = 1;
    if (i != 0)
      lft[i] = i - 1;
    else
      lft[i] = -1;
    if (i != len - 1)
      rig[i] = i + 1;
    else
      rig[i] = -1;
  }
  while (1) {
    int f = 0;
    for (int i = 0; i < len && i != -1; i = rig[i]) {
      if (exi[i] && rig[i] != -1 && exi[rig[i]] && s[i] != s[rig[i]]) {
        ans += 2;
        f = 1;
        if (lft[i] != -1) {
          rig[lft[i]] = rig[rig[i]];
          lft[rig[rig[i]]] = lft[i];
        }
        exi[i] = exi[rig[i]] = 0;
        rig[i] = lft[i] = -1;
      }
    }
    if (!f) break;
  }
  printf("%d\n", ans);
  return 0;
}
