#include <bits/stdc++.h>
using namespace std;

int main() {
    string str; 
    int counter = 0;
    vector<int> idx;

    cin >> str; 

    for (int i=0; i<str.size()-1; i++){

        int num_same = 1;
        int j = i+1;

        while (str.at(i) == str.at(j)) {
            num_same++;
            j++;
        }

        if (num_same % 3 == 2) {
            counter += (num_same / 3 + 1);
        }
        
        else {
            counter += (num_same / 3);
        }

        i = j - 1;

    }
    
    cout << str.size() - counter << endl;

}