#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int ans;
string s;
int main(){
    cin>>s;
    for(int i=0;i<s.size();i++){
        int j=i;
        while(s[j]==s[i]) j++;
        ans++;
        i=j-1;
    }
    cout<<min(ans+1,s.size())<<endl;
    return 0;
}