import java.io.IOException;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.PrintWriter;



public class easy {
    public static int sum(int a) {
        String str = String.valueOf(a);
        int sum = 0;
        for (int i = 0; i < str.length(); i++) {
            sum += str.charAt(i) - '0';
        }
        return sum;
    }
    public static void main(String[] ars) throws IOException {
        BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter w = new BufferedWriter(new PrintWriter(System.out));
        String l;
        int a, as, b, bs;
        while (true) {
            l = r.readLine();
            a = Integer.parseInt(l);
            if (a == 0) break;
            as = sum(a);
            b = 11;
            while (true) {
                bs = sum(a * b);
                //System.out.println("cc " + as + " " + bs);
                if (as == bs) break;
                else b++;
            }
            System.out.println(b);
            //w.write("" + b);
            //w.newLine();
            //w.flush();
        }
        //r.readLine();
        //w.write("a");
        //w.flush();
    }
}
