#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  for (;;) {
    int c = 0;
    string t = "";
    for (int i = 0; i < s.size();) {
      if (i == s.size() - 1) {
        string u = s.substr(s.size() - 1, 1);
        t += u;
        break;
      }
      if (s[i] != s[i + 1]) {
        ans += 2;
        i += 2;
        c = 1;
      } else {
        string y = s.substr(i, 1);
        t += y;
        i++;
      }
    }
    if (c == 0) {
      cout << ans << endl;
      return 0;
    }
    s = t;
  }
}
