#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int count = 0;
  int N = S.length();
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (S.size() == 1) break;
    if (S.size() == 2) {
      if (S[0] != S[1]) {
        N += 2;
        break;
      } else {
        break;
      }
    }
    if (S.begin() + i == S.begin() + i + 1) continue;
    S.erase(S.begin() + i + 1, S.begin() + i + 3);
    i--;
    count++;
  }
  ans = N - S.length();
  cout << ans << endl;
  return 0;
}
