#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  char top;
  cin >> S;
  int ans = 0;
  vector<char> s(S.size());
  stack<char> sta;
  for (int i = 0; i < S.size(); i++) {
    s[i] = S[i];
  }
  bool loop = true;
  while (loop) {
    loop = false;
    for (int i = 0; i < s.size() - 1; i++) {
      if (s[i] != s[i + 1]) {
        loop = true;
        ans = ans + 2;
        int length = s.size();
        for (int j = 0; j < length - (i + 1) + 1; j++) {
          sta.push(s[s.size() - 1]);
          s.pop_back();
        }
        sta.pop();
        sta.pop();
        for (int j = 0; j < length - (i + 1) - 1; j++) {
          top = sta.top();
          sta.pop();
          s.push_back(top);
        }
      }
    }
  }
  cout << ans << endl;
}
