import java.util.*;
import java.lang.*;
import java.io.*;
class Main
{
{
long x, x1, x2;
long c;
int k = 0;
Scanner sc
= new Scanner
(System.
in); x = sc.nextInt();
boolean f = false;
while(!f){
x1 = x;
x2 = 0;
while (x1 > 0)
{
c = x1%10;
x1 /= 10;
x2 = x2*10 + c;
}
if (x == x2)
{
f = true;
break;
}
else {
x += x2;
k++;
}
}
}
}
aW1wb3J0IGphdmEudXRpbC4qOwppbXBvcnQgamF2YS5sYW5nLio7CmltcG9ydCBqYXZhLmlvLio7CgpjbGFzcyBNYWluCnsKCXB1YmxpYyBzdGF0aWMgdm9pZCBtYWluIChTdHJpbmdbXSBhcmdzKSB0aHJvd3MgamF2YS5sYW5nLkV4Y2VwdGlvbgoJewoJCWxvbmcgeCwgeDEsIHgyOwoJCWxvbmcgYzsKCQlpbnQgayA9IDA7CgkJU2Nhbm5lciBzYyA9IG5ldyBTY2FubmVyKFN5c3RlbS5pbik7CgkJeCA9IHNjLm5leHRJbnQoKTsKCQlib29sZWFuIGYgPSBmYWxzZTsKCQl3aGlsZSghZil7CgkJCXgxID0geDsKCQkJeDIgPSAwOwoJCQl3aGlsZSAoeDEgPiAwKQoJCQl7CgkJICAgIAljID0geDElMTA7CgkJICAgICAgICB4MSAvPSAxMDsKCQkgICAgICAJeDIgPSB4MioxMCArIGM7CgkJCX0KCQkJaWYgKHggPT0geDIpCgkJCXsKCQkJCVN5c3RlbS5vdXQuZm9ybWF0KCIlZCIsIGspOwoJCQkJZiA9IHRydWU7IAoJCQkJYnJlYWs7CgkJCX0gCgkJCWVsc2UgeyAKCQkJCXggKz0geDI7CgkJCQlrKys7IAoJCQl9CgkJfQoJfQp9