import java.io.BufferedReader; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ import java.io.InputStreamReader; /** * * @author cteam01 */ public class easy { /** * @param args the command line arguments */ public static void main(String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); String line; int n; while ((line = br.readLine()) != null) { n = Integer.parseInt(line); if (n == 0) break; int sump = sum(n); for (int p = 11; p < 32000; p++) { if (sum(p*n) == sump) { System.out.println(p); break; } } } } private static int sum(int a) { int sum = 0; while (a > 0) { sum += a%10; a = a/10; } return sum; } }