#include <bits/stdc++.h>
using namespace std;
string s;
bool ok(int i) {
    return i == 1 || (s[i] != s[i - 1] && s[i - 1] != s[i - 2]);
}

bool ok2(int j) {
    return j < 4 || (s[j - 1] != s[j - 3] && s[j - 2] != s[j - 4]);
}

int f[200005], g[200005];

int main() {

    cin >> s;
    s += '*';

    int n = s.length();
    f[0] = 0;
    g[0] = 0;
    for (int i = 1; i < n; i++) {
        if (ok(i, s)) {
            f[i] = f[i - 1] + 1;
        }
        if (ok2(i, s) && i > 1) {
            g[i] = g[i - 2] + 1;
        }
        if (i > 1) {
                g[i] = max(g[i], f[i - 2] + 1);
        }
        f[i] = max(f[i], g[i - 1] + 1);

        //cout << i << " " << f[i] << " " << g[i] << "\n";
    }
    cout << max(g[n - 1], f[n - 1]);

    /*
    int res = 0;
    int cnt = 0;
    int lim = 0;

    for (int i = 0; i < n - 1; i++) {
        if (lim == 0) {
            res++;
            lim ^= 1;
        } else {
            cnt++;
            if (cnt == 2) {
                cnt = 0;
                res++;
                lim ^= 1;
            } else
            if (s[i] != s[i - 1] && s[i] != s[i + 1]) {
                res++;
                cnt = 0;
            }
        }

    }
    cout << res;
    */
    return 0;
}
