#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll tcs(ll n)
{
ll res=0;
while (n>0)
{
res+=n%10;
n/=10;
}
return res;
}
int main ()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n;
cin>>n;
while (gcd(n,tcs(n))==1)
{
n++;
}
cout<<n;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgbGwgbG9uZyBsb25nCmxsIHRjcyhsbCBuKQp7CiAgICBsbCByZXM9MDsKICAgIHdoaWxlIChuPjApCiAgICB7CiAgICAgICAgcmVzKz1uJTEwOwogICAgICAgIG4vPTEwOwogICAgICAgIAogICAgfQogICAgcmV0dXJuIHJlczsKfQppbnQgbWFpbiAoKQp7CiAgIGlvc19iYXNlOjpzeW5jX3dpdGhfc3RkaW8oMCk7CmNpbi50aWUoMCk7CiAgICBsbCBuOwogICAgY2luPj5uOwogICAgd2hpbGUgKGdjZChuLHRjcyhuKSk9PTEpCiAgICB7CiAgICAgICAgbisrOwogICAgICAgIAogICAgfQogICAgY291dDw8bjsKfQ==