#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = 4 * atan(1);

#define sz(x) (int)(x).size()
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair <int, int>
#define vi vector<int>
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define vpi vector<pair<int, int>>
#define vpd vector<pair<double, double>>
#define pd pair<double, double>

#define f0r(i,a) for(int i=0;i<a;i++)
#define f1r(i,a,b) for(int i=a;i<b;i++)
#define trav(a, x) for (auto& a : x)

template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
  cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}

void fast_io(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
void io(string taskname){
    string fin = taskname + ".in";
    string fout = taskname + ".out";
    const char* FIN = fin.c_str();
    const char* FOUT = fout.c_str();
    freopen(FIN, "r", stdin);
   // freopen(FOUT, "w", stdout);
    fast_io();
}
const int MAX = 2e5 + 5;
int dp[MAX][3];
int main(){
    fast_io();
    string s;
    getline(cin, s);
    int n = sz(s);
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    f0r(i, MAX){
        f0r(j, 3){
            dp[i][j] = -100;
        }
    }
    dp[0][1] = 1;
    dp[1][2] = 1;
    if(s[0] != s[1]){
        dp[1][1] = 2;
    }
    f1r(i, 2, n){
        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);
        dp[i][2] = dp[i-2][1]+1;
        if(i>2){
            if(s[i] != s[i-2] || s[i-1] != s[i-3]){
                dp[i][2] = max(dp[i][2], dp[i-2][2]+1);
            }
        }
    }
    cout << max(dp[n-1][1], dp[n-2][2]) << endl;
    return 0;
}
