#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  string S2;
  string S3;
  string S4;
  S2 = S;
  if (S.size() >= 2) {
    for (int i = 0; i < S.size(); i++) {
      if (S[i] != S[i + 1]) {
        S2[i] = '2';
        S2[i + 1] = '2';
        i++;
      }
      if (i >= S.size() - 2) break;
    }
    for (int i = 0; i < S2.size(); i++) {
      if (S2[i] != '2') {
        S3.push_back(S2[i]);
      }
    }
    for (int i = 0; i < S3.size(); i++) {
      if (S3[i] != S3[i + 1]) {
        S3[i] = '2';
        S3[i + 1] = '2';
        i++;
      }
      if (i >= S3.size() - 2) break;
    }
    for (int i = 0; i < S3.size(); i++) {
      if (S3[i] != '2') {
        S4.push_back(S3[i]);
      }
    }
    cout << S.size() - S4.size() << endl;
  } else
    cout << 0 << endl;
}
