#include
#include
#include
#include
#include
#include
using namespace std;
int sledna_vrednost(int broj) {
int tmp = broj;
int sum = 0;
while(tmp > 0) {
sum += tmp % 10;
tmp /= 10;
}
return broj + sum;
}
int main() {
int potok;
cin >> potok;
int potok1 = 1;
int potok3 = 3;
int potok9 = 9;
while(potok != potok1 and potok != potok3 and potok != potok9) {
while(potok1 < potok) {
potok1 = sledna_vrednost(potok1);
}
while(potok3 < potok) {
potok3 = sledna_vrednost(potok3);
}
while(potok9 < potok) {
potok9 = sledna_vrednost(potok9);
}
if(potok != potok1 and potok != potok3 and potok != potok9) {
potok = sledna_vrednost(potok);
}
}
if(potok == potok1) {
cout << 1 << " ";
}
else if(potok == potok3) {
cout << 3 << " ";
}
else {
cout << 9 << " ";
}
cout << potok << endl;
return 0;
}