import java.io.BufferedReader; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.IOException; import java.io.InputStreamReader; /** * * @author cteam05 */ public class easy { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static int M = 11; static int SNasobku = -1; static int nasobek; static int N, SN; /**3021 * @param args the command line arguments */ public static void main(String[] args) throws IOException { while (true) { N = Integer.parseInt(br.readLine()); //System.out.println("n je " + N); if (N == 0) { break; } //System.out.println("soucet je " + soucetCifer(N)); SNasobku = -1; SN = soucetCifer(N); for (M = 11; SNasobku != SN; M++) { nasobek = M * N; SNasobku = soucetCifer(nasobek); } M--; System.out.println(M); } } public static int soucetCifer(int N) { int zbytek = N; int SoucetN = 0; while (zbytek != 0) { SoucetN += zbytek % 10; zbytek /= 10; } return SoucetN; } }