#include<bits/stdc++.h>
using namespace std;

typedef unsigned long long ll;

int main() {
    string n; cin >> n;
    ll ns = n.length();
    bool used[10];
    ll last[10];
    int cur = n[0] - '0';
    used[cur] = true;
    last[cur] = 0;
    ll sol = 0;
    for(ll i = 1; i < ns; i++) {
        cur = n[i] - '0';
        if (last[cur] != i - 1 && used[cur]) {
            sol++;
            if (i + 1 < ns) {
                cur = n[i+1] - '0';
            }
        }
        used[cur] = true;
        last[cur] = i;
    }
    cout << sol << "\n";
    return 0;
}