#include <bits/stdc++.h>
using namespace std;
bool check[100001];
int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int res = 0;
  string s;
  int n;
  cin >> s;
  while (1) {
    int prev = res;
    memset(check, false, sizeof(check));
    for (int i = 0; i < s.length() - 1; i++) {
      if (check[i]) {
        continue;
      }
      if (s[i] != s[i + 1]) {
        check[i] = true;
        check[i + 1] = true;
        res += 2;
      }
    }
    if (prev == res) {
      break;
    }
    string t;
    for (int i = 0; i < s.length(); i++) {
      if (!check[i]) {
        t += s[i];
      }
    }
    if (t.length() == 0) {
      break;
    }
    s = t;
  }
  cout << res << '\n';
  return 0;
}
