#include <bits/stdc++.h>
using namespace std;
int main(void) {
  string s;
  cin >> s;
  int length = s.size();
  int ans = 0;
  int count = 0;
  int a = 0;
  int check[s.size()];
  while (count <= 100000) {
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] != s[i + 1]) {
        check[a] = i;
        a++;
        i++;
      }
    }
    if (a == 0) break;
    for (int i = a - 1; i >= 0; i--) {
      s.erase(s.begin() + check[i], s.begin() + check[i] + 2);
      ans++;
    }
    a = 0;
    count++;
    if (ans == length / 2) break;
  }
  cout << ans * 2 << endl;
  return 0;
}
