using System;

namespace ConsoleApp1
{
    class Program
    {

        static void odvoji(int a, int n,ref int[] a1)
        {
            int i, pom = a, x = 0;
            for(i=0;i<n;i++)
            {
                x *= 10;
                x += a % 10;
                a /= 10;
            }
            for (i = 0; i <= n; i++)
            {
                a1[i] = x % 10;
                x /= 10;
            }
        }

        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            string s = Convert.ToString(x);
            int n = s.Length, i = 0, br = 0, j = 0;
            int[] x1 = new int[n + 1];
            odvoji(x, n, ref x1);
            for (i = 0; i < n-2; i++)
            {
                for (j = i; j < n - 2; j++)
                {
                    if (x1[i] <= x1[j + 2])
                    {
                        for (j = i; j < n - 2; j++) ;
                        if (x1[i] > x1[i + 1] && x1[i + 1] < x1[j + 2])
                        {
                            x1[i + 1] = x1[i];
                            br++;
                        }
                        else
                            if (x1[i] > x1[i + 1] && x1[i + 1] == x1[j+2])
                            {
                                x1[i] = x1[i + 1];
                            br++;
                            }
                    }
                }
            }
            Console.WriteLine(br);
        }
    }
}