#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s;
  cin>>s;
  c1=0;
  for(int i=0;i<n-1;i++)
  {
    if(s[i]!=s[i+1])
    {
      c+=2*(c1/3)+(c1%3==0)?0:1;
      c++;
      c1=0;
    }
    if(s[i]==s[i+1])
    {
      if(c1==0)
        c1++;
      c1++;
    }
  }
  cout<<c;
  return 0;
}