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

int main() {
	int ans=1;
	string s;
	cin >> s;
	int i = 0; 
	int n = 1;
	int m=s.size();

	while (i != m-2) {
		if (s.at(i) == s.at(i + 1)) {
			n++;
		}
		if (s.at(i) != s.at(i + 1)) {
			ans++;
		}
		i++;
	}

	
	cout << ans+foo(n) << endl;
}


int foo(int n) {
	return (2 * n + 1) / 3;
}