/* package whatever; // don't place package name! */

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

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	static int f(int n){return n>0?n%10<9?26523308>>n%10*3&7:2+f(n/10):2;}
	public static void main (String[] args) throws java.lang.Exception
	{
		System.out.println(f(1999));
		System.out.println(f(12345));
		System.out.println(f(999999));
		System.out.println(f(5699999));
		System.out.println(f(2147483647));
	}
}