#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
using M = map<int, int>;
int main() {
  string s, t = "";
  cin >> s;
  int b;
  int ans = 0;
  do {
    t = "";
    b = 0;
    for (int i = 0; i < (int)(s.size()); i++) {
      if (i + 1 < s.size() && s[i] != s[i + 1]) {
        ans += 2;
        i++;
        b = 1;
      } else {
        t += s[i];
      }
    }
    s = t;
  } while (b);
  cout << ans << endl;
  return 0;
}
