using System;

namespace Zadatak4
{
    class Zadatak4
    {
        static void Main(string[] args)
        {
            int num = Convert.ToInt32(Console.ReadLine());
            int digits = Convert.ToInt32(num.ToString().Length);
            for (int i = 0; i < digits - 3; i++)
            {
                num = num / 10;
            }
            int num3 = num % 10;
            int num2 = (num % 100) / 10;
            int num1 = num / 100;
            if (num1 <= num2 && num2 <= num3)
                Console.WriteLine("0");
            else
            {
                if ((num1 <= num2) && (num2 > num3 || num1 > num3))
                    Console.WriteLine("1");
                else if ((num1 > num2) && (num1 > num3 || num2 <= num3))
                    Console.WriteLine("1");
                else
                    Console.WriteLine("2");
            }

        }
    }
}