import java.util.Scanner; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /** * * @author cteam46 */ public class easy { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); sc.nextLine(); int i = 11, Nsum = 0; while( N != 0 ) { i = 11; Nsum = cifsum(N); // System.out.println("Ciferny soucet pro" + N+ " je " + Nsum); while( true ) { if( cifsum( N * i ) == Nsum ) { System.out.println( i ); break; } i++; } N = sc.nextInt(); sc.nextLine(); } } /* public static int cifsum( int a ) { int mul = 1, sum = 0; int[] ciphers = {100000, 10000, 1000, 100, 10, 1}; int i = 0; while( a > 0 ) { mul = (int) a / ciphers[i]; sum += mul; a -= mul*ciphers[i]; i++; } return sum; }*/ public static int cifsum( int a ) { String s = a+""; int res =0; for(int i = 0; i < s.length(); i++) { int cifra = Integer.parseInt(""+s.charAt(i)); res += cifra; } return res; } }