#include #include using namespace std; int addDigits(int); int main(){ int in, add; while(1){ cin >> in; if(in==0) break; add = addDigits(in); for(int i=11;;i++){ if(add==addDigits(in*i)){ cout << i<< endl; break; } } //cout << " " << addDigits(in) << endl; } return 0; } int addDigits(int n){ int soucet = 0; int modulo; int modulo2 = 0; for(int i = 1;n>((int)pow(10,i-1));i++){ //cout << (int) pow(10,i) << " " << i << endl; modulo = n % ((int) pow(10,i)); //cout << modulo << endl; soucet += (modulo - modulo2)/((int) pow(10,(i-1))); //cout << soucet << endl; modulo2 = modulo; } return soucet; }