using System;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Convert.ToInt32(Console.ReadLine());
            int brojac=0;
            while (n>0)
            {
                brojac++;
                n /= 10;
            }
            string[] m = new string[brojac];
            int i=0;
            while (n>0)
            {
                int cifra = n % 10;
                m[i] = cifra.ToString();
                i++;
                n /= 10;

            }

            int h = 0;
                int a = Convert.ToInt32(m[1]);
                int b = Convert.ToInt32(m[2]);
                int c = Convert.ToInt32(m[0]);
                if (a>b)
                {
                    if (a>=c)
                    {
                        b = a;
                    h++;
                    }
                    else { b = a; c = a;h += 2; }
                }
                else
                {
                    if (b>=c)
                    {
                        a = b;
                    h++;
                    }
                    else { b = c;a = c; h += 2; }
                }
                m[1] = a.ToString();
                m[2] = b.ToString();
                m[0] = c.ToString();
            Console.WriteLine(h);
            


        }
    }
}