#include <bits/stdc++.h>
int main() {
  char S[100010];
  fgets(S, sizeof(S), stdin);
  int N = strlen(S);
  N--;
  char c = S[0];
  int count_0 = 0;
  int count_1 = 0;
  int n = 0;
  int temp = n;
  int sum = 0;
  while (true) {
    while (n < N && S[n] == c) {
      n++;
    }
    count_1 = count_1 + n - temp;
    temp = n;
    while (n < N && S[n] != c) {
      n++;
    }
    count_0 = count_0 + n - temp;
    temp = n;
    if (count_1 >= count_0) {
      sum = sum + count_0;
      count_1 = count_1 - count_0;
      count_0 = 0;
    } else {
      sum = sum + count_1;
      count_1 = 0;
      count_0 = count_0 - count_1;
    }
    if (n == N) {
      break;
    }
  }
  printf("%d\n", sum * 2);
  return 0;
}
