#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&...tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, set<T> &s) {
  os << "{";
  for (auto p : s) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}
int N;
int main() {
  string S;
  cin >> S;
  N = S.length();
  VEC<int> C;
  int row = 1;
  for (long long i = (0); i < (long long)(N - 1); ++i) {
    if (S[i] != S[i + 1]) {
      C.push_back(row);
      row = 1;
    } else {
      row++;
    }
  }
  C.push_back(row);
  int cnt = 0;
  for (long long i = (0); i < (long long)(C.size() - 1); ++i) {
    if (C[i] > 1 && C[i + 1] > 1) {
      C[i]--;
      C[i + 1]--;
      cnt++;
    }
  }
  LL sum = 0;
  for (long long i = (0); i < (long long)(C.size()); ++i) {
    int s = C[i] / 3 * 2 + (C[i] % 3 > 0 ? 1 : 0);
    sum += s;
  }
  cout << cnt + sum << endl;
  return 0;
}
