//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,no-stack-protector") 
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
 
#include <bits/stdc++.h>
 
#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;
 
using namespace std;
 
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
 
typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;
 
const int N = 2e5 + 123;
int n , m, k;
string s;
int a[N];
int dp[N][5];
main(){
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	cin >> s;
	int ans = 0 , n = sz(s);
	s = '$' + s;
	dp[1][1] = 1;
	if(s[1] != s[2])
		dp[1][1] = 2;
	dp[2][2] = 1;		
	for(int i = 3 ; i <= n ; i++){
		if(s[i] != s[i - 1])
			dp[i][1] = dp[i - 1][1] + 1;
	 	dp[i][1] = max(dp[i][1] , dp[i - 1][2] + 1);
		if(i != 3 && (s[i - 3] != s[i - 1] || s[i - 2] != s[i]))
			dp[i][2] = dp[i - 2][2] + 1;
		dp[i][2] = max(dp[i][2] , dp[i - 2][1] + 1);
//		cout << dp[i][1] << ' ' << dp[i][2] << '\n';	
	}
	cout << max(dp[n][1] , dp[n][2]);
//	cout << dp[n][1] << ' ' << dp[n][2] << ' ';
}