#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define ll long long
#define M 1000000007
#define sz(a) (ll)a.size()
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define sep(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll dp[100005][2];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    if(s.size()==1)
    {
    	cout<<1<<"\n";
    	return 0;
    }
    dp[0][1]=1;
    dp[1][2]=1;
    if(s[1]!=s[0])
    	dp[1][1]=2;
    rep(i,2,sz(s))
    {
    	if(dp[i-1][2])
    	dp[i][1]=1+dp[i-1][2];
    	if(dp[i-1][1]&&s[i]!=s[i-1])
    		dp[i][1]=max(dp[i][1],1+dp[i-1][1]);
    	dp[i][2]=1+dp[i-2][1];
    	if(dp[i-2][2]&&!(s[i-3]==s[i-1]&&s[i-2]==s[i]))
    		dp[i][2]=max(dp[i][2],1+dp[i-2][2]);
    }
    cout<<max(dp[sz(s)-1][1],dp[sz(s)-1][2]);
}
