#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_temp>
using smaller_queue = priority_queue<Q_temp, vector<Q_temp>, greater<Q_temp> >;
const ll MOD = (ll)(1e9 + 7);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};
inline ll CEIL(ll a, ll b) { return (a + b - 1) / b; }
void finish() {
  cout << -1 << endl;
  exit(0);
}
int f(int a) {
  if (a % 3 == 0)
    return (a / 3) * 2;
  else
    return (a / 3) * 2 + 1;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << setiosflags(ios::fixed);
  string s;
  cin >> s;
  char before_c = '0';
  int temp = 0;
  vector<int> v;
  for (auto c : s) {
    if (c != before_c) {
      before_c = c;
      v.push_back(0);
    }
    (*v.rbegin())++;
  }
  int cnt = 0;
  for (ll i = 0; i < (ll)(v.size() - 1); ++i) {
    if (v[i] % 2 == 0 && v[i + 1] % 2 == 0) {
      v[i]--, v[i + 1]--;
      cnt++;
    }
  }
  for (auto a : v) {
    cnt += f(a);
  }
  cout << cnt << endl;
  return 0;
}
