#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int ans = 0;
  bool k = false;
  while (a.size() > 2) {
    string c;
    k = false;
    for (int i = 0; i < a.size(); i++) {
      if (i + 1 <= a.size() - 1 && a[i] != a[i + 1]) {
        ans++;
        i = i + 1;
        k = true;
      } else {
        c.push_back(a[i]);
      }
    }
    a = c;
    if (!k) break;
  }
  if (a.size() == 2 && a[0] != a[1]) ans++;
  cout << ans * 2 << endl;
  return 0;
}
