#include<bits/stdc++.h>
#define int long long
using namespace std;
int N;
bool huiwen(int a){
int b=0,c=a;
while(a>0){
b=b*10+a%10;
a/=10;
}
if(c==b) return true;
else return false;
}
signed main(){
scanf("%d",&N);
for(int i=N+1;;i++){
if(huiwen(i)){
printf("%d",i);
return 0;
}
}
return 0;
}