#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long INF = 1LL << 60;
int main() {
  string S;
  cin >> S;
  queue<int> q1, q2;
  for (int i = 0; i < S.size(); i++) {
    q1.push(S.at(i));
  }
  int counter = 0;
  int a, b;
  a = q1.front();
  q1.pop();
  bool flag = true;
  int counter2 = 0;
  while (counter2 <= q1.size()) {
    if (q1.size()) {
      b = q1.front();
      q1.pop();
    } else
      break;
    if (a != b) {
      counter += 2;
      if (q1.empty()) break;
      a = q1.front();
      q1.pop();
      counter2 = 0;
    } else {
      q1.push(a);
      a = b;
    }
    counter2++;
  }
  cout << counter << endl;
}
