#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int f = 0, x = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') x = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    f = (f << 1) + (f << 3) + ch - '0', ch = getchar();
  return f * x;
}
int ans = 0, b, k, f = 0;
char s[1000009], ss[1000009], zz = 1;
int main() {
  scanf("%s", s + 1);
  int l = strlen(s + 1);
  ss[zz] = s[1];
  for (int i = 2; i <= l; i++) {
    if (s[i] != ss[zz] && zz != 0)
      zz--, ans += 2;
    else
      zz++, ss[zz] = s[i];
  }
  printf("%d\n", ans);
  return 0;
}
