#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  stack<char> amari;
  char prev = 'n';
  int ans = 0;
  for (long long i = 0; i < (long long)(s.size()); ++i) {
    if (prev == 'n') {
      prev = s[i];
      continue;
    }
    if (prev != s[i]) {
      ans += 2;
      prev = 'n';
    } else {
      if (!amari.empty() && amari.top() != prev) {
        ans += 2;
        prev = s[i];
        amari.pop();
      } else {
        amari.push(prev);
        prev = s[i];
      }
    }
  }
  if (!amari.empty()) {
    if (prev != amari.top()) ans += 2;
  }
  cout << ans << endl;
  return 0;
}
