#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

    fast();
      
 
    str s;
    cin >> s;
    ll k = 0;
   
    ll c=0,used[s.size()]={0};
    f(i,1,s.size())
    {
        if(s[i]==s[i-1]&&used[i-1]==0)
        {
            c=1;
            used[i]=1;

        }
        if(s[i]!=s[i-1])
        {
            if(c==1)
            {

                k+=2;
                c=0;
                

            }
            else if(c==0&&s[i]!=s[i+1]&&i+1<s.size()&&i!=s.size()-1)
            {
                k++;
               
            } 
            else if(c==0&&i==s.size()-1)
                k++;
        }
        // cout<<s[i]<<" "<<k<<edl;
     
    }
    cout<<k;
  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
