import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int solve (string s)
{
	auto n = s.length.to !(int);
	s ~= ".?!";
	auto f = new int [3] [n + 4];
	f[1][1] = 1;
	f[2][2] = 1;
	foreach (i; 0..n)
	{
		foreach (j; 1..3)
		{
			if (f[i][j])
			{
				f[i + 3 - j][3 - j] = max
				    (f[i + 3 - j][3 - j], f[i][j] + 1);
				if (s[i - j..i] != s[i..i + j])
				{
					f[i + j][j] = max
					    (f[i + j][j], f[i][j] + 1);
				}
			}
		}
	}
	return max (f[n][1], f[n][2]);
}

void main ()
{
	string s;
	while ((s = readln.strip) != "")
	{
		writeln (solve (s));
	}
}
