#include <bits/stdc++.h>

using namespace std;

int main()
{
    int a, b, c, rez = 0, cif[10] = {};
    char n[100001];
    cin >> n;

    a = n[0] - '0';
    cif[a]++;

    b = n[1] - '0';

    int i = 2;

    while(n[i] != NULL)
    {
        c = n[i] - '0';

        if (a == c && b != a)
        {
            rez++;
            cif[b]--;
            b = a;

        }
        else if(a != b && cif[b] > 0)
        {
            rez++;
            cif[b]--;
            b = a;
        }
        else if(a != b && b != c) cif[b]++;
        a = b;
        b = c;
        i++;
    }

    if(a != b && cif[b] > 0)
        rez++;
    cout << rez;

}