import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		long x, x1, x2;
		long c;
		int k = 0;
		Scanner sc = new Scanner(System.in);
		x = sc.nextInt();
		boolean f = false;
		while(!f){
			x1 = x;
			x2 = 0;
			while (x1 > 0)
			{
		    	c = x1%10;
		        x1 /= 10;
		      	x2 = x2*10 + c;
			}
			if (x == x2)
			{
				System.out.format("%d", k);
				f = true; 
				break;
			} 
			else { 
				x += x2;
				k++; 
			}
		}
	}
}