#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-9;
template <class T, class C>
void chmax(T& a, C b) {
  a > b ?: a = b;
}
template <class T, class C>
void chmin(T& a, C b) {
  a < b ?: a = b;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n = 0, k = 0, ans = 0, c = 0;
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != s[i + 1]) {
      ans++;
      n = k;
      k = 0;
    } else {
      k++;
      if (n > 0 && k > 0) {
        ans++;
        c++;
      }
      if (k > 1) {
        ans++;
      }
    }
  }
  cout << ans - 1 << endl;
}
