#include <bits/stdc++.h>
using namespace std;
inline long long read() {
  long long x = 0, f = 1;
  char ch = getchar();
  for (; ch < '0' || ch > '9'; ch = getchar())
    if (ch == '-') f = -f;
  for (; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
  return x * f;
}
inline void chkmin(int &a, int b) {
  if (a > b) a = b;
}
inline void chkmax(int &a, int b) {
  if (a < b) a = b;
}
int top, S[1000005];
int main() {
  string s;
  cin >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    if (s[i] != s[S[top]])
      top--;
    else
      S[++top] = i;
  }
  cout << n - top;
}
