#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  vector<char> t(s.length());
  int ans = 0;
  int isempty = 0;
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] == s[i + 1]) {
      if (isempty > 0) {
        if (t.back() != s[i + 1]) {
          ans++;
          t.pop_back();
          isempty--;
          i++;
        }
      }
      t.push_back(s[i]);
      isempty++;
    } else {
      ans++;
      i++;
    }
  }
  if ((isempty > 0) && (t.back() != s[s.length() - 1])) {
    ans++;
    t.pop_back();
    isempty--;
  }
  cout << ans * 2 << endl;
  return 0;
}
