#include<bits/stdc++.h>
using namespace std;
void jw(string x,int y)
{
if (y<0)
{
string z=x;
x="1";
x=x+z;
return ;
}
x[y]++;
if (x[y]>'9')
{
x[y]=0;
jw(x,y-1);
}
return ;
}
int main()
{
string x;
cin>>x;
string y=x;
reverse(y.begin(),y.end());
if (x==y)
{
jw(x,x.length()-1);
}
int l=0,r=x.length()-1;
while (l<r)
{
if (x[l]>=x[r])
{
x[r]=x[l];
}
else
{
jw(x,r-1);
x[r]=x[l];
}
l++;
r--;
}
cout<<x;
}