#include <bits/stdc++.h>
using namespace std;
using lli = long long;
string s;
int eliminate(string x) {
  int m = x.size();
  int c = 0;
  vector<bool> seen(m);
  for (int i = 0; i < m - 1; i++) {
    if (seen[i]) continue;
    if (x[i] != x[i + 1]) {
      seen[i] = seen[i + 1] = true;
      c++;
    }
  }
  if (c == 0) return 0;
  string t = "";
  for (int i = 0; i < m; i++) {
    if (!seen[i]) t += x[i];
  }
  return c + eliminate(t);
}
int main(void) {
  cin >> s;
  cout << 2 * eliminate(s) << endl;
  return 0;
}
