#include <bits/stdc++.h>
using namespace std;
int main() {
  char a;
  char s[100001];
  int cnt = 0, ans = 0;
  while (scanf("%c", &a)) {
    if (a == '\n') break;
    ans++;
    if (cnt == 0) continue;
    if (a != s[cnt])
      cnt--;
    else
      s[++cnt] = a;
  }
  printf("%d", ans - cnt);
}
